import json
import math
import cmath
import random
import os
import re
import asyncio
import time
import copy
from botpy import logging
from botpy.message import GroupMessage, Message
from tools import txt_exist, txt_write, player_id, player_name, player_read, player_write, player_number, exp_up, bag_add, bag_reduce, send_message, player_number


async def attribute_count(message):
    if hasattr(message.author, 'member_openid'):
        number = message.author.member_openid
    elif hasattr(message.author, 'user_openid'):
        number = message.author.user_openid
    uid = await player_id(number)
    with open(f"data/bag/{uid}.txt", 'r') as f:
        equip = json.load(f)
        equip_names = list(equip["装备"].values())
        hp = 0
        mp = 0
        attack = 0
        magic_attack = 0
        defend = 0
        magic_defend = 0
        hit = 0
        avoid = 0
        crit = 0
        crit_resist = 0
        crit_harm = 0
        crit_harm_resist = 0
        tough = 0
        speed = 0
        attack_reduce = 0
        magic_reduce = 0
        attack_add = 0
        magic_add = 0
        effect = {}
        fumo = {}
    for item in equip_names:
        if item:
            if "·" in item:
                guanming = True
                item_name = item.split("+")[0]
                equip_name = item_name.split("·")[0]
            else:
                guanming = False
                equip_name = item
            with open(f"data/equipment/{equip_name}.txt", 'r') as f:
                this_equip = json.load(f)
                hp += this_equip["属性"].get("最大生命", 0)
                mp += this_equip["属性"].get("最大魔力", 0)
                attack += this_equip["属性"].get("物攻", 0)
                magic_attack += this_equip["属性"].get("魔攻", 0)
                defend += this_equip["属性"].get("物防", 0)
                magic_defend += this_equip["属性"].get("魔防", 0)
                hit += this_equip["属性"].get("命中", 0)
                avoid += this_equip["属性"].get("闪避", 0)
                crit += this_equip["属性"].get("暴击", 0)
                crit_resist += this_equip["属性"].get("暴免", 0)
                crit_harm += this_equip["属性"].get("暴伤", 0)
                crit_harm_resist += this_equip["属性"].get("暴抗", 0)
                tough += this_equip["属性"].get("韧性", 0)
                speed += this_equip["属性"].get("速度", 0)
                attack_reduce = round(float((1 - (100 - attack_reduce) * (100 - (this_equip["属性"].get("物理减伤", 0))) / 10000) * 100), 2)
                magic_reduce = round(float((1 - (100 - magic_reduce) * (100 - (this_equip["属性"].get("魔法减伤", 0))) / 10000) * 100), 2)
                attack_add += this_equip["属性"].get("物理增伤", 0)
                magic_add += this_equip["属性"].get("魔法增伤", 0)

                if "套装" in this_equip:
                    if len(this_equip["套装"]) != 0:
                        for equip_effect in this_equip["套装"]:
                            if equip_effect not in effect:
                                effect[equip_effect] = 1
                            else:
                                effect[equip_effect] += 1

                if guanming:
                    equip_fumo = item.split("=")[1]
                    for prop in equip_fumo.strip('&').split('&'):
                        name, value = prop.split('*')
                        # 如果属性名已经在字典中，累加属性值
                        if name in fumo:
                            fumo[name] += int(value)
                        # 如果属性名不在字典中，添加新的键值对
                        else:
                            fumo[name] = int(value)


    with open(f"data/player/{uid}.txt", 'r') as f:
        item = json.load(f)
        """
        装备套装效果
        """
        if "特殊效果" not in item:
            item["特殊效果"] = []
        item_effect = [x for x in item["特殊效果"] if "装备*" not in x]
        for effect_key, effect_value in effect.items():
            if effect_key == "轻甲" and effect_value >= 3 and effect_value < 5:
                item_effect.append("装备*轻甲穿着")
            if effect_key == "轻甲" and effect_value >= 5:
                item_effect.append("装备*轻甲武装")
            if effect_key == "中甲" and effect_value >= 3 and effect_value < 5:
                item_effect.append("装备*中甲穿着")
            if effect_key == "中甲" and effect_value >= 5:
                item_effect.append("装备*中甲武装")
            if effect_key == "重甲" and effect_value >= 3 and effect_value < 5:
                item_effect.append("装备*重甲穿着")
            if effect_key == "重甲" and effect_value >= 5:
                item_effect.append("装备*重甲武装")
            if effect_key == "贤者之歌" and effect_value >= 1 and effect_value < 3:
                item_effect.append("装备*若有若无的回音")
            if effect_key == "贤者之歌" and effect_value >= 3 and effect_value < 5:
                item_effect.append("装备*清晰悦耳的音符")
            if effect_key == "贤者之歌" and effect_value >= 5 and effect_value < 7:
                item_effect.append("装备*周天流转的旋律")
            if effect_key == "贤者之歌" and effect_value >= 7 and effect_value < 9:
                item_effect.append("装备*婉转回旋的独唱")
            if effect_key == "贤者之歌" and effect_value >= 9:
                item_effect.append("装备*独步天籁的绝响")
            if effect_key == "破法" and effect_value == 1:
                item_effect.append("装备*破法Ⅰ")
            if effect_key == "破法" and effect_value == 2:
                item_effect.append("装备*破法Ⅱ")
            if effect_key == "破法" and effect_value == 3:
                item_effect.append("装备*破法Ⅲ")
            if effect_key == "反震Ⅰ" and effect_value == 1:
                item_effect.append("装备*反震Ⅰ")
            if effect_key == "反震Ⅱ" and effect_value == 1:
                item_effect.append("装备*反震Ⅱ")
            if effect_key == "反震Ⅲ" and effect_value == 1:
                item_effect.append("装备*反震Ⅲ")
            if effect_key == "治疗提升" and effect_value == 1:
                item_effect.append("装备*治疗提升Ⅰ")
            if effect_key == "伤害加深" and effect_value == 1:
                item_effect.append("装备*伤害加深Ⅰ")
            if effect_key == "光附魔" and effect_value >= 1:
                item_effect.append("装备*光附魔")
            if effect_key == "暗附魔" and effect_value >= 1:
                item_effect.append("装备*暗附魔")
            if effect_key == "邪视" and effect_value == 1:
                item_effect.append("装备*邪视")
            if effect_key == "诅咒" and effect_value == 1:
                item_effect.append("装备*诅咒")
            if effect_key == "黎明" and effect_value == 1:
                item_effect.append("装备*黎明")
            if effect_key == "撕裂" and effect_value == 1:
                item_effect.append("装备*撕裂")
            if effect_key == "嗜血" and effect_value == 1:
                item_effect.append("装备*嗜血")
            if effect_key == "山崩" and effect_value == 1:
                item_effect.append("装备*山崩")
            if effect_key == "史史史" and effect_value == 3:
                item_effect.append("装备*史史史")
            if effect_key == "献爱心" and effect_value == 3:
                item_effect.append("装备*献爱心")


        item["特殊效果"] = item_effect



        """
        体魄血脉天赋效果
        """
        item_effect = item["特殊效果"]
        item_effect = [x for x in item_effect if "体魄*" not in x]
        item_effect = [x for x in item_effect if "血脉*" not in x]
        item_effect = [x for x in item_effect if "天赋*" not in x]
        for x in item["体魄"]:
            item_effect.append("体魄*{}".format(x))
        for x in item["血脉"]:
            item_effect.append("血脉*{}".format(x))
        for x in item["天赋"]:
            item_effect.append("天赋*{}".format(x))

        item["特殊效果"] = item_effect




        """
        技能被动效果
        """
        item_effect = [x for x in item["特殊效果"] if "技能*" not in x]
        passive_skills = ["洪荒之力", "生命吸收", "生命涓流", "不灭意志", "魔力涌动", "元素爆发", "医者仁心", "律者箴言", "杀意感知", "弱点洞察", "其行如风", "瞬息千刃", "圣天赐福", "神力加持", "巨人身躯", "古神血脉", "魔导极致", "法力洪流", "形影不离", "假死替身"]
        for skill1 in passive_skills:
            for skill2 in item["学会技能"]:
                if skill2["名称"] == skill1:
                    item_effect.append(f"技能*{skill1}")
                    break
        item["特殊效果"] = item_effect




        """
        人物效果加成计算
        先清零
        """
        add_list = ["力量", "智力", "敏捷", "体质", "生命", "魔力", "物攻", "魔攻", "物防", "魔防", "命中", "闪避", "暴击", "暴免", "暴伤", "暴抗", "速度", "韧性"]
        for x in add_list:
            item[x]["加成"] = 0

        """
        然后效果累加
        """
        add1 = 0
        add2 = 0
        add3 = 0
        add4 = 0
        if "装备*重甲穿着" in item["特殊效果"]:
            item["生命"]["加成"] += 20
            item["暴免"]["加成"] += 20
            item["暴抗"]["加成"] += 20
            item["韧性"]["加成"] += 20
        if "装备*重甲武装" in item["特殊效果"]:
            item["生命"]["加成"] += 35
            item["暴免"]["加成"] += 35
            item["暴抗"]["加成"] += 35
            item["韧性"]["加成"] += 35
        if "装备*中甲穿着" in item["特殊效果"]:
            item["生命"]["加成"] += 10
            item["魔力"]["加成"] += 10
            item["暴击"]["加成"] += 25
            item["暴伤"]["加成"] += 25
        if "装备*中甲武装" in item["特殊效果"]:
            item["生命"]["加成"] += 18
            item["魔力"]["加成"] += 18
            item["暴击"]["加成"] += 45
            item["暴伤"]["加成"] += 45
        if "装备*轻甲穿着" in item["特殊效果"]:
            item["魔力"]["加成"] += 25
            item["闪避"]["加成"] += 25
            item["速度"]["加成"] += 25
        if "装备*轻甲武装" in item["特殊效果"]:
            item["魔力"]["加成"] += 45
            item["闪避"]["加成"] += 45
            item["速度"]["加成"] += 45
        if "体魄*体质残疾" in item["特殊效果"]:
            item["体质"]["加成"] -= 50
        if "体魄*敏捷残疾" in item["特殊效果"]:
            item["敏捷"]["加成"] -= 50
        if "体魄*力量残疾" in item["特殊效果"]:
            item["力量"]["加成"] -= 50
        if "体魄*智力残疾" in item["特殊效果"]:
            item["智力"]["加成"] -= 50
        if "体魄*体质欠缺" in item["特殊效果"]:
            item["体质"]["加成"] -= 20
        if "体魄*敏捷欠缺" in item["特殊效果"]:
            item["敏捷"]["加成"] -= 20
        if "体魄*力量欠缺" in item["特殊效果"]:
            item["力量"]["加成"] -= 20
        if "体魄*智力欠缺" in item["特殊效果"]:
            item["智力"]["加成"] -= 20
        if "体魄*天生强壮" in item["特殊效果"]:
            item["体质"]["加成"] += 5
            add1 += 1
        if "体魄*天生灵活" in item["特殊效果"]:
            item["敏捷"]["加成"] += 5
            add2 += 1
        if "体魄*天生大力" in item["特殊效果"]:
            item["力量"]["加成"] += 5
            add3 += 1
        if "体魄*天生聪明" in item["特殊效果"]:
            item["智力"]["加成"] += 5
            add4 += 1
        if "体魄*天生强健" in item["特殊效果"]:
            item["体质"]["加成"] += 10
            add1 += 2
        if "体魄*天生灵巧" in item["特殊效果"]:
            item["敏捷"]["加成"] += 10
            add2 += 2
        if "体魄*天生神力" in item["特殊效果"]:
            item["力量"]["加成"] += 10
            add3 += 2
        if "体魄*天生聪慧" in item["特殊效果"]:
            item["智力"]["加成"] += 10
            add4 += 2
        if "体魄*轮回之体" in item["特殊效果"]:
            item["体质"]["加成"] += 15
            add1 += 3
        if "体魄*轮回神体" in item["特殊效果"]:
            item["体质"]["加成"] += 20
            add1 += 4
        if "体魄*荒古圣体" in item["特殊效果"]:
            item["体质"]["加成"] += 25
            add1 += 5
        if "体魄*神灵之体" in item["特殊效果"]:
            item["智力"]["加成"] += 15
            add4 += 3
        if "体魄*仙灵之体" in item["特殊效果"]:
            item["智力"]["加成"] += 20
            add4 += 4
        if "体魄*先天道体" in item["特殊效果"]:
            item["智力"]["加成"] += 25
            add4 += 5
        if "体魄*斗战之体" in item["特殊效果"]:
            item["力量"]["加成"] += 15
            add3 += 3
        if "体魄*斗战神体" in item["特殊效果"]:
            item["力量"]["加成"] += 20
            add3 += 4
        if "体魄*苍天霸体" in item["特殊效果"]:
            item["力量"]["加成"] += 25
            add3 += 5
        if "体魄*瞬之体" in item["特殊效果"]:
            item["敏捷"]["加成"] += 15
            add2 += 3
        if "体魄*影之体" in item["特殊效果"]:
            item["敏捷"]["加成"] += 20
            add2 += 4
        if "体魄*末影黑体" in item["特殊效果"]:
            item["敏捷"]["加成"] += 25
            add2 += 5

        if "装备*若有若无的回音" in item["特殊效果"]:
            item["生命"]["加成"] += 2
            item["魔力"]["加成"] += 2
            item["物攻"]["加成"] += 2
            item["魔攻"]["加成"] += 2
            item["物防"]["加成"] += 2
            item["魔防"]["加成"] += 2
            item["命中"]["加成"] += 2
            item["闪避"]["加成"] += 2
            item["暴击"]["加成"] += 2
            item["暴免"]["加成"] += 2
            item["暴伤"]["加成"] += 2
            item["暴抗"]["加成"] += 2
            item["速度"]["加成"] += 2
            item["韧性"]["加成"] += 2
        if "装备*清晰悦耳的音符" in item["特殊效果"]:
            item["生命"]["加成"] += 5
            item["魔力"]["加成"] += 5
            item["物攻"]["加成"] += 5
            item["魔攻"]["加成"] += 5
            item["物防"]["加成"] += 5
            item["魔防"]["加成"] += 5
            item["命中"]["加成"] += 5
            item["闪避"]["加成"] += 5
            item["暴击"]["加成"] += 5
            item["暴免"]["加成"] += 5
            item["暴伤"]["加成"] += 5
            item["暴抗"]["加成"] += 5
            item["速度"]["加成"] += 5
            item["韧性"]["加成"] += 5
        if "装备*周天流转的旋律" in item["特殊效果"]:
            item["生命"]["加成"] += 8
            item["魔力"]["加成"] += 8
            item["物攻"]["加成"] += 8
            item["魔攻"]["加成"] += 8
            item["物防"]["加成"] += 8
            item["魔防"]["加成"] += 8
            item["命中"]["加成"] += 8
            item["闪避"]["加成"] += 8
            item["暴击"]["加成"] += 8
            item["暴免"]["加成"] += 8
            item["暴伤"]["加成"] += 8
            item["暴抗"]["加成"] += 8
            item["速度"]["加成"] += 8
            item["韧性"]["加成"] += 8 
        if "装备*婉转回旋的独唱" in item["特殊效果"]:
            item["生命"]["加成"] += 12
            item["魔力"]["加成"] += 12
            item["物攻"]["加成"] += 12
            item["魔攻"]["加成"] += 12
            item["物防"]["加成"] += 12
            item["魔防"]["加成"] += 12
            item["命中"]["加成"] += 12
            item["闪避"]["加成"] += 12
            item["暴击"]["加成"] += 12
            item["暴免"]["加成"] += 12
            item["暴伤"]["加成"] += 12
            item["暴抗"]["加成"] += 12
            item["速度"]["加成"] += 12
            item["韧性"]["加成"] += 12
        if "装备*独步天籁的绝响" in item["特殊效果"]:
            item["生命"]["加成"] += 15
            item["魔力"]["加成"] += 15
            item["物攻"]["加成"] += 15
            item["魔攻"]["加成"] += 15
            item["物防"]["加成"] += 15
            item["魔防"]["加成"] += 15
            item["命中"]["加成"] += 15
            item["闪避"]["加成"] += 15
            item["暴击"]["加成"] += 15
            item["暴免"]["加成"] += 15
            item["暴伤"]["加成"] += 15
            item["暴抗"]["加成"] += 15
            item["速度"]["加成"] += 15
            item["韧性"]["加成"] += 15 
        




        

        item["力量"]["等级"] = 0
        item["智力"]["等级"] = 0
        item["体质"]["等级"] = 0
        item["敏捷"]["等级"] = 0
        
        item["力量"]["装备"] = fumo.get("力量", 0)
        item["智力"]["装备"] = fumo.get("智力", 0)
        item["体质"]["装备"] = fumo.get("体质", 0)
        item["敏捷"]["装备"] = fumo.get("敏捷", 0)

        item["力量"]["最终"] = (item["力量"]["等级"] + item["力量"]["基础"] + item["力量"]["加点"] + add3) * (item["力量"]["加成"] + 100) / 100 + item["力量"]["躯体"] + item["力量"]["进化"]
        item["智力"]["最终"] = (item["智力"]["等级"] + item["智力"]["基础"] + item["智力"]["加点"] + add4) * (item["智力"]["加成"] + 100) / 100 + item["智力"]["躯体"] + item["智力"]["进化"]
        item["体质"]["最终"] = (item["体质"]["等级"] + item["体质"]["基础"] + item["体质"]["加点"] + add1) * (item["体质"]["加成"] + 100) / 100 + item["体质"]["躯体"] + item["体质"]["进化"]
        item["敏捷"]["最终"] = (item["敏捷"]["等级"] + item["敏捷"]["基础"] + item["敏捷"]["加点"] + add2) * (item["敏捷"]["加成"] + 100) / 100 + item["敏捷"]["躯体"] + item["敏捷"]["进化"]
        
        """
        进化计算
        """
        if "进化" in item:
            if not any(effect_name == "进化*进化的光辉" for effect_name in item["特殊效果"]):
                item["特殊效果"].append("进化*进化的光辉")
            evolute_class_1 = ["力量", "智力", "体质", "敏捷"]
            for evolute in item["进化"]:
                if evolute["属性"] in evolute_class_1:
                    item[evolute["属性"]]["最终"] *= (100 + float(evolute["数值"])) / 100

        if "进化诅咒" in item:
            evolute_class_11 = ["力量", "智力", "体质", "敏捷"]
            for evolute in item["进化诅咒"]:
                if evolute["属性"] in evolute_class_11:
                    item[evolute["属性"]]["最终"] *= (100 - float(evolute["数值"])) / 100
        """
        进化计算
        """

        if "一转" in item:
            if item["一转"] == "盾守":
                att_to = item["敏捷"]["最终"] * 0.75 + item["智力"]["最终"] * 0.75
                item["敏捷"]["最终"] *= 0.25
                item["智力"]["最终"] *= 0.25
                item["体质"]["最终"] += att_to * 1
            elif item["一转"] == "战士":
                att_to = item["智力"]["最终"] * 0.75
                item["智力"]["最终"] *= 0.25
                item["力量"]["最终"] += att_to * 0.5
                item["敏捷"]["最终"] += att_to * 0.5
            elif item["一转"] == "法师":
                att_to = item["体质"]["最终"] * 0.75 + item["力量"]["最终"] * 0.75
                item["体质"]["最终"] *= 0.25
                item["力量"]["最终"] *= 0.25
                item["智力"]["最终"] += att_to * 1
            elif item["一转"] == "牧师":
                att_to = item["力量"]["最终"] * 0.75 + item["敏捷"]["最终"] * 0.75
                item["力量"]["最终"] *= 0.25
                item["敏捷"]["最终"] *= 0.25
                item["智力"]["最终"] += att_to * 0.5
                item["体质"]["最终"] += att_to * 0.5
            elif item["一转"] == "刺客":
                att_to = item["体质"]["最终"] * 0.75 + item["力量"]["最终"] * 0.5 + item["智力"]["最终"] * 0.5
                item["体质"]["最终"] *= 0.25
                item["力量"]["最终"] *= 0.5
                item["智力"]["最终"] *= 0.5
                item["敏捷"]["最终"] += att_to * 1

        item["力量"]["最终"] += item["力量"]["装备"]
        item["智力"]["最终"] += item["智力"]["装备"]
        item["体质"]["最终"] += item["体质"]["装备"]
        item["敏捷"]["最终"] += item["敏捷"]["装备"]

        
        item["力量"]["最终"] = round((item["力量"]["最终"]), 1)
        item["智力"]["最终"] = round((item["智力"]["最终"]), 1)
        item["体质"]["最终"] = round((item["体质"]["最终"]), 1)
        item["敏捷"]["最终"] = round((item["敏捷"]["最终"]), 1)
        item["生命"]["基础最大"] = (item["体质"]["最终"] * 60 + item["力量"]["最终"] * 50 + item["智力"]["最终"] * 30 + item["敏捷"]["最终"] * 30)
        item["魔力"]["基础最大"] = (item["体质"]["最终"] * 50 + item["力量"]["最终"] * 30 + item["智力"]["最终"] * 70 + item["敏捷"]["最终"] * 20)
        item["物攻"]["基础"] = (item["体质"]["最终"] * 1 + item["力量"]["最终"] * 8 + item["智力"]["最终"] * 0 + item["敏捷"]["最终"] * 8)
        item["魔攻"]["基础"] = (item["体质"]["最终"] * 1 + item["力量"]["最终"] * 0 + item["智力"]["最终"] * 8 + item["敏捷"]["最终"] * 8)
        item["物防"]["基础"] = (item["体质"]["最终"] * 8 + item["力量"]["最终"] * 5 + item["智力"]["最终"] * 0 + item["敏捷"]["最终"] * 2)
        item["魔防"]["基础"] = (item["体质"]["最终"] * 4 + item["力量"]["最终"] * 2 + item["智力"]["最终"] * 7 + item["敏捷"]["最终"] * 2)
        item["命中"]["基础"] = (item["体质"]["最终"] * 0 + item["力量"]["最终"] * 3 + item["智力"]["最终"] * 3 + item["敏捷"]["最终"] * 8)
        item["闪避"]["基础"] = (item["体质"]["最终"] * 4 + item["力量"]["最终"] * 1 + item["智力"]["最终"] * 1 + item["敏捷"]["最终"] * 8)
        item["暴击"]["基础"] = (item["体质"]["最终"] * 0 + item["力量"]["最终"] * 8 + item["智力"]["最终"] * 1 + item["敏捷"]["最终"] * 5)
        item["暴免"]["基础"] = (item["体质"]["最终"] * 8 + item["力量"]["最终"] * 1 + item["智力"]["最终"] * 5 + item["敏捷"]["最终"] * 0)
        item["暴伤"]["基础"] = (item["体质"]["最终"] * 0 + item["力量"]["最终"] * 1 + item["智力"]["最终"] * 8 + item["敏捷"]["最终"] * 5)
        item["暴抗"]["基础"] = (item["体质"]["最终"] * 8 + item["力量"]["最终"] * 5 + item["智力"]["最终"] * 1 + item["敏捷"]["最终"] * 0)
        item["韧性"]["基础"] = (item["体质"]["最终"] * 6 + item["力量"]["最终"] * 2 + item["智力"]["最终"] * 4 + item["敏捷"]["最终"] * 0)
        item["速度"]["基础"] = (item["体质"]["最终"] * 2 + item["力量"]["最终"] * 2 + item["智力"]["最终"] * 2 + item["敏捷"]["最终"] * 8)
        item["生命回复"] = 0
        item["魔力回复"] = 0
        item["最低命中率"] = 0
        item["最低闪避率"] = 0
        item["最低暴击率"] = 0
        item["物理减伤"] = attack_reduce
        item["魔法减伤"] = magic_reduce
        item["物理增伤"] = attack_add
        item["魔法增伤"] = magic_add

        if "血脉*青龙血脉" in item["特殊效果"]:
            item["暴击"]["基础"] += item["等级"] * 50
            item["暴伤"]["基础"] += item["等级"] * 50
            item["物理增伤"] += 10
            item["物理增伤"] += int(item["等级"]) * 0.4
        if "血脉*青龙神血" in item["特殊效果"]:
            item["暴击"]["基础"] += item["等级"] * 75
            item["暴伤"]["基础"] += item["等级"] * 75
            item["物理增伤"] += 20
            item["物理增伤"] += int(item["等级"]) * 0.8
        if "血脉*朱雀血脉" in item["特殊效果"]:
            item["暴击"]["基础"] += item["等级"] * 50
            item["暴伤"]["基础"] += item["等级"] * 50
            item["魔法增伤"] += 10
            item["魔法增伤"] += int(item["等级"]) * 0.4
        if "血脉*朱雀神血" in item["特殊效果"]:
            item["暴击"]["基础"] += item["等级"] * 75
            item["暴伤"]["基础"] += item["等级"] * 75
            item["魔法增伤"] += 20
            item["魔法增伤"] += int(item["等级"]) * 0.8
        if "血脉*白虎血脉" in item["特殊效果"]:
            item["命中"]["基础"] += item["等级"] * 50
            item["闪避"]["基础"] += item["等级"] * 50
            item["速度"]["基础"] += item["等级"] * 50
            item["物理增伤"] += 8
            item["物理增伤"] += int(item["等级"]) * 0.32
            item["魔法增伤"] += 8
            item["魔法增伤"] += int(item["等级"]) * 0.32
        if "血脉*白虎神血" in item["特殊效果"]:
            item["命中"]["基础"] += item["等级"] * 75
            item["闪避"]["基础"] += item["等级"] * 75
            item["速度"]["基础"] += item["等级"] * 75
            item["物理增伤"] += 16
            item["物理增伤"] += int(item["等级"]) * 0.64
            item["魔法增伤"] += 16
            item["魔法增伤"] += int(item["等级"]) * 0.64
        if "血脉*玄武血脉" in item["特殊效果"]:
            item["暴免"]["基础"] += item["等级"] * 40
            item["暴抗"]["基础"] += item["等级"] * 40
            item["韧性"]["基础"] += item["等级"] * 40
            item["物理减伤"] = round(float((1 - (100 - item["物理减伤"]) * (100 - (5 + int(item["等级"]) * 0.2)) / 10000) * 100), 2)
            item["魔法减伤"] = round(float((1 - (100 - item["魔法减伤"]) * (100 - (2.5 + int(item["等级"]) * 0.1)) / 10000) * 100), 2)
        if "血脉*玄武神血" in item["特殊效果"]:
            item["暴免"]["基础"] += item["等级"] * 60
            item["暴抗"]["基础"] += item["等级"] * 60
            item["韧性"]["基础"] += item["等级"] * 60
            item["物理减伤"] = round(float((1 - (100 - item["物理减伤"]) * (100 - (10 + int(item["等级"]) * 0.4)) / 10000) * 100), 2)
            item["魔法减伤"] = round(float((1 - (100 - item["魔法减伤"]) * (100 - (5 + int(item["等级"]) * 0.2)) / 10000) * 100), 2)
        if "血脉*人王血脉" in item["特殊效果"]:
            item["暴击"]["基础"] += item["等级"] * 20
            item["暴伤"]["基础"] += item["等级"] * 20
            item["暴免"]["基础"] += item["等级"] * 20
            item["暴抗"]["基础"] += item["等级"] * 20
            item["命中"]["基础"] += item["等级"] * 20
            item["闪避"]["基础"] += item["等级"] * 20
            item["速度"]["基础"] += item["等级"] * 20
            item["韧性"]["基础"] += item["等级"] * 20
            item["物理增伤"] += 5
            item["物理增伤"] += (int(item["力量"]["加点"]) * 0.45 + int(item["敏捷"]["加点"]) * 0.35)
            item["魔法增伤"] += 5
            item["魔法增伤"] += (int(item["智力"]["加点"]) * 0.45 + int(item["敏捷"]["加点"]) * 0.35)
            item["物理减伤"] = round(float((1 - (100 - item["物理减伤"]) * (100 - (3 + int(item["体质"]["加点"]) * 0.22)) / 10000) * 100), 2)
            item["魔法减伤"] = round(float((1 - (100 - item["魔法减伤"]) * (100 - (1.5 + int(item["体质"]["加点"]) * 0.11)) / 10000) * 100), 2)
        if "血脉*人皇血脉" in item["特殊效果"]:
            item["暴击"]["基础"] += item["等级"] * 30
            item["暴伤"]["基础"] += item["等级"] * 30
            item["暴免"]["基础"] += item["等级"] * 30
            item["暴抗"]["基础"] += item["等级"] * 30
            item["命中"]["基础"] += item["等级"] * 30
            item["闪避"]["基础"] += item["等级"] * 30
            item["速度"]["基础"] += item["等级"] * 30
            item["韧性"]["基础"] += item["等级"] * 30
            item["物理增伤"] += 10
            item["物理增伤"] += (int(item["力量"]["加点"]) * 0.9 + int(item["敏捷"]["加点"]) * 0.7)
            item["魔法增伤"] += 10
            item["魔法增伤"] += (int(item["智力"]["加点"]) * 0.9 + int(item["敏捷"]["加点"]) * 0.7)
            item["物理减伤"] = round(float((1 - (100 - item["物理减伤"]) * (100 - (5 + int(item["体质"]["加点"]) * 0.45)) / 10000) * 100), 2)
            item["魔法减伤"] = round(float((1 - (100 - item["魔法减伤"]) * (100 - (3 + int(item["体质"]["加点"]) * 0.22)) / 10000) * 100), 2)
            """
            转职计算
            """
        x1 = 0
        for i in range(int(item["体质"]["加点"])):
            x1 += 0.95 ** i
        x2 = 0
        for i in range(int(item["力量"]["加点"])):
            x2 += 0.95 ** i
        x3 = 0
        for i in range(int(item["智力"]["加点"])):
            x3 += 0.95 ** i
        x4 = 0
        for i in range(int(item["敏捷"]["加点"])):
            x4 += 0.95 ** i
        if "一转" in item:
            if item["一转"] == "盾守":
                item["物防"]["基础"] += (x1 * 20 + x2 * 40 + x3 * 0 + x4 * 10)
                item["魔防"]["基础"] += (x1 * 20 + x2 * 0 + x3 * 40 + x4 * 10)
                item["暴免"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 80 + x4 * 0)
                item["暴抗"]["基础"] += (x1 * 0 + x2 * 80 + x3 * 0 + x4 * 0)
                item["生命"]["基础最大"] += (x1 * 120 + x2 * 40 + x3 * 40 + x4 * 40)
                item["魔力"]["基础最大"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 20)
                item["命中"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 40)
                item["暴击"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 40)
                item["暴伤"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 40)
            elif item["一转"] == "战士":
                item["生命"]["基础最大"] += (x1 * 120 + x2 * 80 + x3 * 0 + x4 * 0)
                item["魔力"]["基础最大"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 0)
                item["物攻"]["基础"] += (x1 * 0 + x2 * 20 + x3 * 0 + x4 * 0)
                item["物防"]["基础"] += (x1 * 20 + x2 * 20 + x3 * 0 + x4 * 0)
                item["魔防"]["基础"] += (x1 * 10 + x2 * 0 + x3 * 0 + x4 * 0)
                item["命中"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 40)
                item["暴击"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 90 + x4 * 40)
                item["暴伤"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 90 + x4 * 40)
            elif item["一转"] == "法师":
                item["生命"]["基础最大"] += (x1 * 80 + x2 * 0 + x3 * 0 + x4 * 0)
                item["魔力"]["基础最大"] += (x1 * 20 + x2 * 0 + x3 * 120 + x4 * 0)
                item["魔攻"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 20 + x4 * 0)
                item["物防"]["基础"] += (x1 * 10 + x2 * 0 + x3 * 0 + x4 * 0)
                item["魔防"]["基础"] += (x1 * 25 + x2 * 0 + x3 * 10 + x4 * 0)
                item["暴击"]["基础"] += (x1 * 0 + x2 * 90 + x3 * 0 + x4 * 40)
                item["暴伤"]["基础"] += (x1 * 0 + x2 * 90 + x3 * 0 + x4 * 40)
                item["命中"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 40)
            elif item["一转"] == "牧师":
                item["生命"]["基础最大"] += (x1 * 80 + x2 * 40 + x3 * 0 + x4 * 0)
                item["魔力"]["基础最大"] += (x1 * 0 + x2 * 0 + x3 * 40 + x4 * 0)
                item["物防"]["基础"] += (x1 * 20 + x2 * 10 + x3 * 0 + x4 * 0)
                item["魔防"]["基础"] += (x1 * 20 + x2 * 0 + x3 * 10 + x4 * 0)
                item["暴击"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 30)
                item["暴伤"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 30)
                item["物攻"]["基础"] += (x1 * 0 + x2 * 20 + x3 * 0 + x4 * 0)
                item["魔攻"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 20 + x4 * 0)
                item["命中"]["基础"] += (x1 * 0 + x2 * 20 + x3 * 20 + x4 * 30)
                item["闪避"]["基础"] += (x1 * 0 + x2 * 20 + x3 * 20 + x4 * 30)
            elif item["一转"] == "刺客":
                item["生命"]["基础最大"] += (x1 * 80 + x2 * 40 + x3 * 0 + x4 * 0)
                item["魔力"]["基础最大"] += (x1 * 0 + x2 * 0 + x3 * 40 + x4 * 0)
                item["物防"]["基础"] += (x1 * 0 + x2 * 10 + x3 * 0 + x4 * 0)
                item["魔防"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 10 + x4 * 0)
                item["暴免"]["基础"] += (x1 * 40 + x2 * 0 + x3 * 0 + x4 * 0)
                item["暴抗"]["基础"] += (x1 * 40 + x2 * 0 + x3 * 0 + x4 * 0)
                item["物攻"]["基础"] += (x1 * 0 + x2 * 20 + x3 * 0 + x4 * 20)
                item["魔攻"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 20 + x4 * 20)
                item["暴击"]["基础"] += (x1 * 0 + x2 * 20 + x3 * 20 + x4 * 20)
                item["暴伤"]["基础"] += (x1 * 0 + x2 * 20 + x3 * 20 + x4 * 20)
                item["命中"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 20)
                item["闪避"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 20)

        """二转属性"""
        if item.get("二转", "无") == "剑影":
            item["命中"]["基础"] *= 2
        if item.get("二转", "无") == "影忍":
            item["闪避"]["基础"] *= 2
        elif item.get("二转", "无") == "神官":
            item["韧性"]["基础"] *= 2
        elif item.get("二转", "无") == "泰坦":
            item["生命"]["基础最大"] *= 1.5
            item["生命回复"] = round(float((1 - (100 - item["生命回复"]) * (100 - float(5)) / 10000) * 100), 2)
        elif item.get("二转", "无") == "魔导":
            item["魔力"]["基础最大"] *= 1.5
            item["魔力回复"] = round(float((1 - (100 - item["魔力回复"]) * (100 - float(5)) / 10000) * 100), 2)

        
        """进化计算"""
        """进化计算"""
        """进化计算"""
        if "进化" in item:
            evolute_class_2 = ["物攻", "魔攻", "物防", "魔防", "命中", "闪避", "暴击", "暴伤", "暴免", "暴抗", "速度", "韧性"]
            for evolute in item["进化"]:
                if evolute["属性"] in evolute_class_2:
                    item[evolute["属性"]]["基础"] *= (100 + float(evolute["数值"])) / 100
                elif evolute["属性"] == "最大生命":
                    item["生命"]["基础最大"] *= (100 + float(evolute["数值"])) / 100
                elif evolute["属性"] == "最大魔力":
                    item["魔力"]["基础最大"] *= (100 + float(evolute["数值"])) / 100
                elif evolute["属性"] == "生命回复":
                    item["生命回复"] = round(float((1 - (100 - item["生命回复"]) * (100 - float(evolute["数值"])) / 10000) * 100), 2)
                elif evolute["属性"] == "魔力回复":
                    item["魔力回复"] = round(float((1 - (100 - item["魔力回复"]) * (100 - float(evolute["数值"])) / 10000) * 100), 2)
                elif evolute["属性"] == "物理减伤":
                    item["物理减伤"] = round(float((1 - (100 - item["物理减伤"]) * (100 - float(evolute["数值"])) / 10000) * 100), 2)
                elif evolute["属性"] == "魔法减伤":
                    item["魔法减伤"] = round(float((1 - (100 - item["魔法减伤"]) * (100 - float(evolute["数值"])) / 10000) * 100), 2)
        if "进化诅咒" in item:
            evolute_class_21 = ["物攻", "魔攻", "物防", "魔防", "命中", "闪避", "暴击", "暴伤", "暴免", "暴抗", "速度", "韧性"]
            for evolute in item["进化诅咒"]:
                if evolute["属性"] in evolute_class_21:
                    item[evolute["属性"]]["基础"] *= (100 - float(evolute["数值"])) / 100
                elif evolute["属性"] == "最大生命":
                    item["生命"]["基础最大"] *= (100 - float(evolute["数值"])) / 100
                elif evolute["属性"] == "最大魔力":
                    item["魔力"]["基础最大"] *= (100 - float(evolute["数值"])) / 100

        if "装备*重甲穿着" in item["特殊效果"]:
            item["暴免"]["基础"] += item["等级"] * 25
            item["暴抗"]["基础"] += item["等级"] * 25
        if "装备*重甲武装" in item["特殊效果"]:
            item["暴免"]["基础"] += item["等级"] * 50
            item["暴抗"]["基础"] += item["等级"] * 50
        if "装备*中甲穿着" in item["特殊效果"]:
            item["暴击"]["基础"] += item["等级"] * 25
            item["暴伤"]["基础"] += item["等级"] * 25
        if "装备*中甲武装" in item["特殊效果"]:
            item["暴击"]["基础"] += item["等级"] * 50
            item["暴伤"]["基础"] += item["等级"] * 50
        if "装备*轻甲穿着" in item["特殊效果"]:
            item["闪避"]["基础"] += item["等级"] * 25
            item["速度"]["基础"] += item["等级"] * 25
        if "装备*轻甲武装" in item["特殊效果"]:
            item["闪避"]["基础"] += item["等级"] * 50
            item["速度"]["基础"] += item["等级"] * 50

        item["生命"]["基础最大"] += hp + fumo.get("生命", 0)
        item["魔力"]["基础最大"] += mp + fumo.get("魔力", 0)
        item["物攻"]["基础"] += attack + fumo.get("物攻", 0)
        item["魔攻"]["基础"] += magic_attack + fumo.get("魔攻", 0)
        item["物防"]["基础"] += defend + fumo.get("物防", 0)
        item["魔防"]["基础"] += magic_defend + fumo.get("魔防", 0)
        item["命中"]["基础"] += hit + fumo.get("命中", 0)
        item["闪避"]["基础"] += avoid + fumo.get("闪避", 0)
        item["暴击"]["基础"] += crit + fumo.get("暴击", 0)
        item["暴免"]["基础"] += crit_resist + fumo.get("暴免", 0)
        item["暴伤"]["基础"] += crit_harm + fumo.get("暴伤", 0)
        item["暴抗"]["基础"] += crit_harm_resist + fumo.get("暴抗", 0)
        item["韧性"]["基础"] += tough + fumo.get("韧性", 0)
        item["速度"]["基础"] += speed + fumo.get("速度", 0)


#        """加点结算"""
#        result = 0
#        for i in range(item["敏捷"]["加点"]):
#            result += (100 - result) * 0.01
#        item["命中"]["基础"] *= (100 + result) / 100
#        item["闪避"]["基础"] *= (100 + result) / 100
#        item["暴击"]["基础"] *= (100 + result) / 100
#        item["暴伤"]["基础"] *= (100 + result) / 100
#        
#        item["减伤"] = round(float((1 - (100 - item["减伤"]) * (100 - float(item["体质"]["加点"] * 0.5)) / 10000) * 100), 2)
#        
#        result = 0
#        for i in range(item["力量"]["加点"]):
#            result += (50 - result) * 0.01
#        item["物攻"]["基础"] *= (100 + result) / 100
#        result = 0
#        for i in range(item["智力"]["加点"]):
#            result += (50 - result) * 0.01
#        item["魔攻"]["基础"] *= (100 + result) / 100
#        """加点结算"""

        if item["生命"]["基础最大"] < 1:
            item["生命"]["基础最大"] = 1
        item["生命"]["最终"] = item["生命"]["基础最大"] * (item["生命"]["加成"] + 100) / 100
        if item["魔力"]["基础最大"] < 1:
            item["魔力"]["基础最大"] = 1
        item["魔力"]["最终"] = item["魔力"]["基础最大"] * (item["魔力"]["加成"] + 100) / 100
        if item["物攻"]["基础"] < 1:
            item["物攻"]["基础"] = 1
        item["物攻"]["最终"] = item["物攻"]["基础"] * (item["物攻"]["加成"] + 100) / 100
        if item["魔攻"]["基础"] < 1:
            item["魔攻"]["基础"] = 1
        item["魔攻"]["最终"] = item["魔攻"]["基础"] * (item["魔攻"]["加成"] + 100) / 100
        if item["物防"]["基础"] < 1:
            item["物防"]["基础"] = 1
        item["物防"]["最终"] = item["物防"]["基础"] * (item["物防"]["加成"] + 100) / 100
        if item["魔防"]["基础"] < 1:
            item["魔防"]["基础"] = 1
        item["魔防"]["最终"] = item["魔防"]["基础"] * (item["魔防"]["加成"] + 100) / 100
        if item["命中"]["基础"] < 1:
            item["命中"]["基础"] = 1
        item["命中"]["最终"] = item["命中"]["基础"] * (item["命中"]["加成"] + 100) / 100
        if item["闪避"]["基础"] < 1:
            item["闪避"]["基础"] = 1
        item["闪避"]["最终"] = item["闪避"]["基础"] * (item["闪避"]["加成"] + 100) / 100
        if item["暴击"]["基础"] < 1:
            item["暴击"]["基础"] = 1
        item["暴击"]["最终"] = item["暴击"]["基础"] * (item["暴击"]["加成"] + 100) / 100
        if item["暴免"]["基础"] < 1:
            item["暴免"]["基础"] = 1
        item["暴免"]["最终"] = item["暴免"]["基础"] * (item["暴免"]["加成"] + 100) / 100
        if item["暴伤"]["基础"] < 1:
            item["暴伤"]["基础"] = 1
        item["暴伤"]["最终"] = item["暴伤"]["基础"] * (item["暴伤"]["加成"] + 100) / 100
        if item["暴抗"]["基础"] < 1:
            item["暴抗"]["基础"] = 1
        item["暴抗"]["最终"] = item["暴抗"]["基础"]* (item["暴抗"]["加成"] + 100) / 100
        if item["韧性"]["基础"] < 1:
            item["韧性"]["基础"] = 1
        item["韧性"]["最终"] = item["韧性"]["基础"] * (item["韧性"]["加成"] + 100) / 100
        if item["速度"]["基础"] < 1:
            item["速度"]["基础"] = 1
        item["速度"]["最终"] = item["速度"]["基础"] * (item["速度"]["加成"] + 100) / 100

        item["物理增伤"] = round(item["物理增伤"], 2)
        item["魔法增伤"] = round(item["魔法增伤"], 2)
        item["物理减伤"] = round(item["物理减伤"], 2)
        item["魔法减伤"] = round(item["魔法减伤"], 2)





    



    


    """
    技能效果计算
    """

    if "技能*洪荒之力" in item["特殊效果"]:
        skill_level = [skill["等级"] for skill in item["学会技能"] if skill["名称"] == "洪荒之力"] or [0]
        item["物攻"]["最终"] = int(item["物攻"]["最终"] + 0.01 * item["生命"]["最终"] * skill_level[0])
    if "技能*杀意感知" in item["特殊效果"]:
        skill_level = [skill["等级"] for skill in item["学会技能"] if skill["名称"] == "杀意感知"] or [0]
        item["闪避"]["最终"] = int(item["闪避"]["最终"] * (1 + 0.08 * skill_level[0]))
    if "技能*生命涓流" in item["特殊效果"]:
        skill_level = [skill["等级"] for skill in item["学会技能"] if skill["名称"] == "生命涓流"] or [0]
        item["生命"]["最终"] = int(item["生命"]["最终"] * (1 + 0.08 * skill_level[0]))
        item["生命回复"] = round(float((1 - (100 - item["生命回复"]) * (100 - float(skill_level[0] * 0.5)) / 10000) * 100), 2)
    if "技能*魔力涌动" in item["特殊效果"]:
        skill_level = [skill["等级"] for skill in item["学会技能"] if skill["名称"] == "魔力涌动"] or [0]
        item["魔力"]["最终"] = int(item["魔力"]["最终"] * (1 + 0.08 * skill_level[0]))
        item["魔力回复"] = round(float((1 - (100 - item["魔力回复"]) * (100 - float(skill_level[0] * 0.5)) / 10000) * 100), 2)
    if "技能*巨人身躯" in item["特殊效果"]:
        item["生命"]["最终"] += int((item["物防"]["最终"] + item["魔防"]["最终"]) * 4)
        item["物防"]["最终"] = 1
        item["魔防"]["最终"] = 1
    if "技能*其行如风" in item["特殊效果"]:
        item["最低命中率"] = 50
    if "技能*假死替身" in item["特殊效果"]:
        item["最低闪避率"] = 50

    """
    装备效果计算
    """
    if "装备*邪视" in item["特殊效果"]:
        attack_add = item["魔攻"]["最终"] * 0.5
        if attack_add > item["物攻"]["最终"] * 0.2:
            attack_add = item["物攻"]["最终"] * 0.2
        item["物攻"]["最终"] += attack_add
        item["魔攻"]["最终"] = 1



    """
    限时效果计算
    """
    try:
        results = [s for s in item["特殊效果"] if "狂暴之血" in s][0]
        results0 = results.split("*")
        end_time = float(results0[2]) + int(results0[3]) * 60
        if int(float(time.time())) > end_time:
            item["特殊效果"].remove(results)
        else:
            item["物攻"]["最终"] *= 1.25
            item["魔攻"]["最终"] *= 1.25
            item["暴击"]["最终"] *= 2
            item["暴伤"]["最终"] *= 2
            item["命中"]["最终"] *= 2
            item["速度"]["最终"] *= 2

    except IndexError:
        pass




    """
    属性向下取整
    """
    item["生命"]["最终"] = int(item["生命"]["最终"])
    item["魔力"]["最终"] = int(item["魔力"]["最终"])
    item["物攻"]["最终"] = int(item["物攻"]["最终"])
    item["魔攻"]["最终"] = int(item["魔攻"]["最终"])
    item["物防"]["最终"] = int(item["物防"]["最终"])
    item["魔防"]["最终"] = int(item["魔防"]["最终"])
    item["命中"]["最终"] = int(item["命中"]["最终"])
    item["闪避"]["最终"] = int(item["闪避"]["最终"]) 
    item["暴击"]["最终"] = int(item["暴击"]["最终"]) 
    item["暴免"]["最终"] = int(item["暴免"]["最终"])
    item["暴伤"]["最终"] = int(item["暴伤"]["最终"])
    item["暴抗"]["最终"] = int(item["暴抗"]["最终"])
    item["韧性"]["最终"] = int(item["韧性"]["最终"])
    item["速度"]["最终"] = int(item["速度"]["最终"])

    if item.get("效果", None) == None:
        item["生命"]["当前最大"] = item["生命"]["最终"]
        item["魔力"]["当前最大"] = item["魔力"]["最终"]
        item["魔攻"]["当前"] = item["魔攻"]["最终"]
        item["魔攻"]["当前"] = item["魔攻"]["最终"]
        item["物攻"]["当前"] = item["物攻"]["最终"]
        item["魔攻"]["当前"] = item["魔攻"]["最终"]
        item["物防"]["当前"] = item["物防"]["最终"]
        item["魔防"]["当前"] = item["魔防"]["最终"]
        item["命中"]["当前"] = item["命中"]["最终"] 
        item["闪避"]["当前"] = item["闪避"]["最终"] 
        item["暴击"]["当前"] = item["暴击"]["最终"] 
        item["暴免"]["当前"] = item["暴免"]["最终"]
        item["暴伤"]["当前"] = item["暴伤"]["最终"]
        item["暴抗"]["当前"] = item["暴抗"]["最终"] 
        item["韧性"]["当前"] = item["韧性"]["最终"]
        item["速度"]["当前"] = item["速度"]["最终"]
    
    if "灵阶" not in item:
        item["灵阶"] = "1"
    with open(f"data/player/{uid}.txt", 'w') as f:
        json.dump(item, f, ensure_ascii=False, indent=4)
    return f"属性刷新完成"


async def team_create(message):
    if hasattr(message.author, 'member_openid'):
        number = message.author.member_openid 
    elif hasattr(message.author, 'user_openid'):    
        number = message.author.user_openid
    with open("data/player.txt", 'r') as f:
        data = json.load(f)
        for item in data:
            if item.get("number") == number:
                uid = item["id"]
                break
           
    with open("data/team.txt", 'r') as f:
        team = json.load(f)
        found = False
        for item in team:
            if uid in item["成员"]:
                found = True
                txt = "\n【你已经在队伍里了哟！】"
                await send_message(message, 0, 1, txt)
                return
        if not found:
            ids = set()
            for item in team:
                ids.add(item['id'])
            new_id = 1
            while new_id in ids:
                new_id += 1
            new_team = {"id": new_id, "成员": [uid]}
            team.append(new_team)
            with open("data/team.txt", 'w') as f:
                json.dump(team, f, ensure_ascii=False, indent=4)
            await txt_write("player", "number", number, "队伍中", "队长")
            txt = "\n创建了队伍[{}]\n发送[加入队伍{}]加入".format(new_id, new_id)

            await send_message(message, 0, 1, txt)
            return


async def team_join(message):
    if hasattr(message.author, 'member_openid'):
        number = message.author.member_openid 
    elif hasattr(message.author, 'user_openid'):    
        number = message.author.user_openid
    with open("data/player.txt", 'r') as f:
        data = json.load(f)
        for item in data:
            if item.get("number") == number:
                id = item["id"]
                break

    with open("data/team.txt", 'r') as f:
        team = json.load(f)
        found = False
        for item in team:
            if id in item["成员"]:
                txt = f"\n【你已经在队伍里了哟！】"

                await send_message(message, 0, 1, txt)
                return

            if not found:
                team_id = message.content[4:]
        
        for item in team:
            if str(item["id"]) == str(team_id):
                if len(item["成员"]) >= 4:
                    txt = f"\n【队伍[{team_id}]已经满员了！】"

                    await send_message(message, 0, 1, txt)
                    return

                else:
                    item["成员"].append(id)
                    with open("data/team.txt", 'w') as f:
                        json.dump(team, f, ensure_ascii=False, indent=4)
                    await txt_write("player", "number", number, "队伍中", "队员")
                    txt = f"\n【你加入了队伍[{team_id}]】\n发送[队伍信息]查看"

                    await send_message(message, 0, 1, txt)
                    return


async def team_leave(message):
    if hasattr(message.author, 'member_openid'):
        number = message.author.member_openid 
    elif hasattr(message.author, 'user_openid'):    
        number = message.author.user_openid
    with open("data/player.txt", 'r') as f:
        data = json.load(f)
        for item in data:
            if item.get("number") == number:
                id = item["id"]
                break
           
    with open("data/team.txt", 'r') as f:
        team = json.load(f)
        found = False
        for item in team:
            if id in item["成员"]:
                item["成员"].remove(id)
                team_id = item["id"]
                found = True
                if not item["成员"]:
                    team.remove(item)
                    with open("data/team.txt", 'w') as f:
                        json.dump(team, f, ensure_ascii=False, indent=4)
                    await txt_write("player", "number", number, "队伍中", "否")
                    await txt_write("player", "number", number, "状态", "行动")
                    txt = f"\n你退出了队伍[{team_id}]！\n由于人数不足，队伍[{team_id}]已解散"

                    await send_message(message, 0, 1, txt)
                    return

                with open("data/team.txt", 'w') as f:
                    json.dump(team, f, ensure_ascii=False, indent=4)
                await txt_write("player", "number", number, "队伍中", "否")
                await txt_write("player", "number", number, "状态", "行动")
                txt = f"\n你退出了队伍[{team_id}]！"

                await send_message(message, 0, 1, txt)
                return

        if not found:
            txt = f"\n你不在队伍中！"

            await send_message(message, 0, 1, txt)
            return


async def team_list(message):
    txt = "\n===❈队伍列表❈==="
    with open("data/team.txt", 'r') as f: 
        team = json.load(f)
        if len(team) == 0:
            txt += "\n【空】"
        for t in team:
            txt += "\n【队伍[{}]】".format(t["id"])
            if len(t["成员"]) >= 4:
                txt += "（已满员）"
            for uid in t["成员"]:
                name = await player_name(uid)
                txt += f"\n☞{name}"

    await send_message(message, 0, 1, txt)
    return


async def team_infor(message):
    txt = "\n===❈队伍信息❈==="
    if hasattr(message.author, 'member_openid'):
        number = message.author.member_openid 
    elif hasattr(message.author, 'user_openid'):    
        number = message.author.user_openid
    with open("data/player.txt", 'r') as f:
        data = json.load(f)
        for item in data:
            if item.get("number") == number:
                id = item["id"]
                break
    
    with open("data/team.txt", 'r') as f:
        team = json.load(f)
    found = False
    for item in team:
        if id in item["成员"]:
            found = True
            team_player = item["成员"]
            break
    if not found:
        txt = "\n【你不在队伍中！】"
        await send_message(message, 0, 1, txt)
        return
    else:
        for index, uid in enumerate(team_player):
            with open(f"data/player/{uid}.txt", 'r') as f:
                player_data = json.load(f)
            if index == 0:
                txt += "\n【队长】"
            else:
                txt += "\n【队员{}】".format(index)
            skills = [v for v in player_data["装备技能"].values() if v != ""]
            result = "[" + "][".join(str(v) for v in skills) + "]"
            job = player_data.get("一转", "未转职")
            txt += "{}-<Lv.{}>\n职业：{}\n技能：{}".format(player_data["nickname"], player_data["等级"], job, result)
        await send_message(message, 0, 1, txt)
        return



async def battle_initialization(monster_name, monster_level, message, which = None):
    if hasattr(message.author, 'member_openid'):
        number = message.author.member_openid 
    elif hasattr(message.author, 'user_openid'):    
        number = message.author.user_openid
    with open("data/player.txt", 'r') as f:
        data = json.load(f)
        for item in data:
            if item.get("number") == number:
                item["状态"] = "战斗"
                id = item["id"]
                with open("data/player.txt", 'w') as f:
                    json.dump(data, f, ensure_ascii=False, indent=4)
                break
    with open("data/team.txt", 'r') as f:
        team = json.load(f)
        found = False
        player = []
        for item in team:
            if id in item["成员"]:
                found = True
                player = item["成员"]
                break
        if not found:
            player.append(id)
    player_people_number = len(player)
    battle_list = {"玩家": [], "敌人": [], "回合": 1}

    if_saint_buff = False
    for object0 in player:
        with open(f"data/player/{object0}.txt", 'r') as f:
            object_saint = json.load(f)
        for object_skill in object_saint["学会技能"]:
            if object_skill["名称"] == "圣天赐福":
                if_saint_buff = True
                saint_buff_最大生命 = math.ceil(object_saint["生命"]["最终"] * 0.1)
                saint_buff_最大魔力 = math.ceil(object_saint["魔力"]["最终"] * 0.1)
                saint_buff_双攻 = math.ceil(object_saint["物攻"]["最终"] * 0.05 + object_saint["魔攻"]["最终"] * 0.05)
                saint_buff_双防 = math.ceil(object_saint["物防"]["最终"] * 0.05 + object_saint["魔防"]["最终"] * 0.05)
                saint_buff_命中 = math.ceil(object_saint["命中"]["最终"] * 0.2 + object_saint["物攻"]["最终"] * 0.05 + object_saint["魔攻"]["最终"] * 0.05)
                saint_buff_闪避 = math.ceil(object_saint["闪避"]["最终"] * 0.2 + object_saint["物防"]["最终"] * 0.05 + object_saint["魔防"]["最终"] * 0.05)
                saint_buff_暴击 = math.ceil(object_saint["暴击"]["最终"] * 0.2 + object_saint["物攻"]["最终"] * 0.05 + object_saint["魔攻"]["最终"] * 0.05)
                saint_buff_暴伤 = math.ceil(object_saint["暴伤"]["最终"] * 0.2 + object_saint["物攻"]["最终"] * 0.05 + object_saint["魔攻"]["最终"] * 0.05)
                saint_buff_暴免 = math.ceil(object_saint["暴免"]["最终"] * 0.2 + object_saint["物防"]["最终"] * 0.05 + object_saint["魔防"]["最终"] * 0.05)
                saint_buff_暴抗 = math.ceil(object_saint["暴抗"]["最终"] * 0.2 + object_saint["物防"]["最终"] * 0.05 + object_saint["魔防"]["最终"] * 0.05)
                saint_buff_速度 = math.ceil(object_saint["速度"]["最终"] * 0.2 + object_saint["物攻"]["最终"] * 0.05 + object_saint["魔攻"]["最终"] * 0.05)
                saint_buff_韧性 = math.ceil(object_saint["韧性"]["最终"] * 0.2 + object_saint["物防"]["最终"] * 0.05 + object_saint["魔防"]["最终"] * 0.05)
                break
        if if_saint_buff:
            break

    for object0 in player:
        if_skill_形影不离 = False
        player_num = await player_number(object0)
        await txt_write("player", "number", player_num, "状态", "战斗")
        with open(f"data/player/{object0}.txt", 'r') as f:
            data = json.load(f)
        uid = data["id"]
        nickname = data["nickname"]
        level = data["等级"]
        effect = []
        str0 = data["力量"]["最终"]
        int0 = data["智力"]["最终"]
        vit0 = data["体质"]["最终"]
        agi0 = data["敏捷"]["最终"]
        hp = data["生命"]
        mp = data["魔力"]
        attack = data["物攻"]
        magic_attack = data["魔攻"]
        defend = data["物防"]
        magic_defend = data["魔防"]
        hit = data["命中"]
        avoid = data["闪避"]
        crit = data["暴击"]
        crit_resist = data["暴免"]
        crit_harm = data["暴伤"]
        crit_harm_resist = data["暴抗"]
        tough = data["韧性"]
        speed = data["速度"]
        if if_saint_buff:
            hp["最终"] += saint_buff_最大生命
            hp["当前最大"] += saint_buff_最大生命
            hp["当前"] += saint_buff_最大生命
            mp["最终"] += saint_buff_最大魔力
            mp["当前最大"] += saint_buff_最大魔力
            mp["当前"] += saint_buff_最大魔力
            attack["最终"] += saint_buff_双攻
            attack["当前"] += saint_buff_双攻
            magic_attack["最终"] += saint_buff_双攻
            magic_attack["当前"] += saint_buff_双攻
            defend["最终"] += saint_buff_双防
            defend["当前"] += saint_buff_双防
            magic_defend["最终"] += saint_buff_双防
            magic_defend["当前"] += saint_buff_双防
            hit["最终"] += saint_buff_命中
            hit["当前"] += saint_buff_命中
            avoid["最终"] += saint_buff_闪避
            avoid["当前"] += saint_buff_闪避
            crit["最终"] += saint_buff_暴击
            crit["当前"] += saint_buff_暴击
            crit_resist["最终"] += saint_buff_暴免
            crit_resist["当前"] += saint_buff_暴免
            crit_harm["最终"] += saint_buff_暴伤
            crit_harm["当前"] += saint_buff_暴伤
            crit_harm_resist["最终"] += saint_buff_暴抗
            crit_harm_resist["当前"] += saint_buff_暴抗
            tough["最终"] += saint_buff_韧性
            tough["当前"] += saint_buff_韧性
            speed["最终"] += saint_buff_速度
            speed["当前"] += saint_buff_速度
            effect.append({"名称": "圣天赐福", "类型": "光环", "次数": 0, "层数": 0, "回合": 999})

        auto = data.get("自动战斗", "否")
        auto_sequence = data.get("自动战斗顺序", "0")
        matched_skills = []
        for i in range(1, 10):
            skill = data["装备技能"][f"技能{i}"]
            if skill:
                for skill0 in data["学会技能"]:
                    if skill0["名称"] == skill:
                        matched_skills.append(skill0)
                        break

        effect_all = ["史史史", "献爱心"]
        for effect0 in effect_all:
            for effect1 in data["特殊效果"]:
                if effect0 in effect1:
                    effect.append({"名称": effect0, "类型": "特殊", "次数": 0, "层数": 0, "回合": 999})
                    break

        equipment_effect = ["伤害加深Ⅰ", "破法Ⅰ", "光附魔", "暗附魔", "治疗提升Ⅰ", "邪视", "诅咒", "黎明", "撕裂", "嗜血", "山崩", "反震Ⅰ", "反震Ⅱ", "反震Ⅲ"]
        for effect0 in equipment_effect:
            for effect1 in data["特殊效果"]:
                if effect0 in effect1:
                    if effect0 == "反震Ⅰ":
                        effect.append({"名称": effect0, "类型": "装备", "数值": 15, "次数": 0, "层数": 0, "回合": 999})
                    elif effect0 == "反震Ⅱ":
                        effect.append({"名称": effect0, "类型": "装备", "数值": 30, "次数": 0, "层数": 0, "回合": 999})
                    elif effect0 == "反震Ⅲ":
                        effect.append({"名称": effect0, "类型": "装备", "数值": 50, "次数": 0, "层数": 0, "回合": 999})
                    else:
                        effect.append({"名称": effect0, "类型": "装备", "数值": 0, "次数": 0, "层数": 0, "回合": 999})
                    break
            

        passive_skills = ["洪荒之力", "生命吸收", "生命涓流", "不灭意志", "魔力涌动", "元素爆发", "医者仁心", "律者箴言", "杀意感知", "弱点洞察", "其行如风", "瞬息千刃", "圣天赐福", "神力加持", "巨人身躯", "古神血脉", "魔导极致", "法力洪流", "形影不离", "假死替身"]
        for skill1 in passive_skills:
            for skill2 in data["学会技能"]:
                if skill2["名称"] == skill1:
                    skill_level = skill2.get("等级", 0)
                    skill_name = skill1
                    if skill_name == "其行如风":
                        effect.append({"名称": "其行如风", "类型": "职业", "目标": "自身", "属性": "", "数值": 0, "回合": 999})
                    elif skill_name == "瞬息千刃":
                        effect.append({"名称": "瞬息千刃", "类型": "职业", "目标": "自身", "属性": "无限连击", "层数": 0, "回合": 999})
                    elif skill_name == "圣天赐福":
                        effect.append({"名称": "圣天赐福", "类型": "职业", "目标": "自身", "属性": "", "层数": 0, "回合": 999})
                    elif skill_name == "神力加持":
                        effect.append({"名称": "神力加持", "类型": "职业", "目标": "自身", "属性": "", "层数": 0, "回合": 999})
                    elif skill_name == "巨人身躯":
                        effect.append({"名称": "巨人身躯", "类型": "职业", "目标": "自身", "属性": "", "层数": 0, "回合": 999})
                    elif skill_name == "古神血脉":
                        effect.append({"名称": "古神血脉", "类型": "职业", "目标": "自身", "属性": "", "层数": 0, "回合": 999})
                    elif skill_name == "魔导极致":
                        effect.append({"名称": "魔导极致", "类型": "职业", "目标": "自身", "属性": "", "层数": 0, "回合": 999})
                    elif skill_name == "法力洪流":
                        effect.append({"名称": "法力洪流", "类型": "职业", "目标": "自身", "属性": "", "层数": 0, "回合": 999})
                    elif skill_name == "形影不离":
                        if_skill_形影不离 = True
                        effect.append({"名称": "形影不离", "类型": "职业", "目标": "自身", "属性": "", "层数": 0, "回合": 999})
                    elif skill_name == "假死替身":
                        effect.append({"名称": "假死替身", "类型": "职业", "目标": "自身", "属性": "", "层数": 0, "回合": 999})
                    else:
                        effect.append({"名称": skill1, "类型": "被动", "等级": skill_level, "层数": 0, "回合": 999})
                    break



        battle_list["玩家"].append({"uid": uid, "昵称": nickname, "等级": level, "力量": str0, "智力": int0, "体质": vit0, "敏捷": agi0, "生命": hp, "魔力": mp, "物攻": attack, "魔攻": magic_attack, "物防": defend, "魔防": magic_defend, "命中": hit, "闪避": avoid, "暴击": crit, "暴免": crit_resist, "暴伤": crit_harm, "暴抗": crit_harm_resist, "韧性": tough, "速度": speed, "最低命中率": {"基础": data["最低命中率"], "当前": data["最低命中率"]}, "最低闪避率": {"基础": data["最低闪避率"], "当前": data["最低闪避率"]}, "最低暴击率": {"基础": data["最低暴击率"], "当前": data["最低暴击率"]}, "生命回复": {"基础": data["生命回复"], "当前": data["生命回复"]}, "魔力回复": {"基础": data["魔力回复"], "当前": data["魔力回复"]}, "物理减伤": {"基础": data["物理减伤"], "当前": data["物理减伤"]}, "魔法减伤": {"基础": data["魔法减伤"], "当前": data["魔法减伤"]}, "物理增伤": {"基础": data["物理增伤"], "当前": data["物理增伤"]}, "魔法增伤": {"基础": data["魔法增伤"], "当前": data["魔法增伤"]}, "物理穿透": {"基础": data["物理穿透"], "当前": data["物理穿透"]}, "魔法穿透": {"基础": data["魔法穿透"], "当前": data["魔法穿透"]}, "技能": matched_skills, "自动战斗": auto, "自动战斗顺序": auto_sequence, "出招": "", "仇恨": 1, "累计伤害": 0, "累计承伤": 0, "效果": effect, "一转": data.get("一转", "无"), "二转": data.get("二转", "无")})

        if if_skill_形影不离:
            nickname0 = "{}·影".format(nickname)
            shadow_uid = int("1000000{}".format(uid))
            effect0 = [in_effect for in_effect in effect if (in_effect["类型"] == "被动" or in_effect["类型"] == "职业")]
            battle_list["玩家"].append({"uid": shadow_uid, "主人uid": uid, "昵称": nickname0, "等级": level, "力量": str0, "智力": int0, "体质": vit0, "敏捷": agi0, "生命": hp, "魔力": mp, "物攻": attack, "魔攻": magic_attack, "物防": defend, "魔防": magic_defend, "命中": hit, "闪避": avoid, "暴击": crit, "暴免": crit_resist, "暴伤": crit_harm, "暴抗": crit_harm_resist, "韧性": tough, "速度": speed, "最低命中率": {"基础": data["最低命中率"], "当前": data["最低命中率"]}, "最低闪避率": {"基础": data["最低闪避率"], "当前": data["最低闪避率"]}, "最低暴击率": {"基础": data["最低暴击率"], "当前": data["最低暴击率"]}, "生命回复": {"基础": data["生命回复"], "当前": data["生命回复"]}, "魔力回复": {"基础": data["魔力回复"], "当前": data["魔力回复"]}, "物理减伤": {"基础": data["物理减伤"], "当前": data["物理减伤"]}, "魔法减伤": {"基础": data["魔法减伤"], "当前": data["魔法减伤"]}, "物理增伤": {"基础": data["物理增伤"], "当前": data["物理增伤"]}, "魔法增伤": {"基础": data["魔法增伤"], "当前": data["魔法增伤"]}, "物理穿透": {"基础": data["物理穿透"], "当前": data["物理穿透"]}, "魔法穿透": {"基础": data["魔法穿透"], "当前": data["魔法穿透"]}, "技能": matched_skills, "自动战斗": auto, "自动战斗顺序": auto_sequence, "出招": "", "仇恨": 0, "累计伤害": 0, "累计承伤": 0, "效果": effect0, "一转": data.get("一转", "无"), "二转": data.get("二转", "无"), "是否出手": "否"})

    for in_list_player in battle_list["玩家"]:
        for in_player_skill in in_list_player["技能"]:
            if in_player_skill["名称"] in ["剑刃风暴", "神圣戒律", "血肉拥抱", "魔力乱流", "暗杀"]:
                in_player_skill["冷却"] = 5

    with open(f"data/monster/{monster_name}.txt", 'r') as f:
        data = json.load(f)
        item = {'id': 0, 'nickname': monster_name, "一转" : "无", "力量": {"基础": 0, "躯体": 0, "加点": 0, "装备": 0, "最终": 0}, "智力": {"基础": 0, "躯体": 0, "加点": 0, "装备": 0, "最终": 0}, "体质": {"基础": 0, "躯体": 0, "加点": 0, "装备": 0, "最终": 0}, "敏捷": {"基础": 0, "躯体": 0, "加点": 0, "装备": 0, "最终": 0}, "体魄":[], "血脉":[], "天赋":[], "等级": 0, "经验": {"最大": 1, "当前": 0}, "生命": {"基础最大": 0, "当前最大": 0, "当前": 0}, "魔力": {"基础最大": 0, "当前最大": 0, "当前": 0}, "物攻": {"基础": 0, "当前": 0}, "魔攻": {"基础": 0, "当前": 0}, "物防": {"基础": 0, "当前": 0}, "魔防": {"基础": 0, "当前": 0}, "命中": {"基础": 0, "当前": 0}, "闪避": {"基础": 0, "当前": 0}, "暴击": {"基础": 0, "当前": 0}, "暴免": {"基础": 0, "当前": 0}, "暴伤": {"基础": 0, "当前": 0}, "暴抗": {"基础": 0, "当前": 0}, "韧性": {"基础": 0, "当前": 0}, "速度": {"基础": 0, "当前": 0}, "装备技能": {"数量": 1, "技能1": "", "技能2": "", "技能3": "", "技能4": "", "技能5": "", "技能6": "", "技能7": "", "技能8": "", "技能9": "", "技能10": ""}, "学会技能": [], "掉落": [], "经验": 0}
        front = ""
        which_1 = ["大力", "神力", "聪明", "聪慧", "灵活", "灵巧", "强壮", "强健", "全能", "超能", "庞大", "犀利", "胆小", "精明", "谨慎", "狠毒", "稳重", "无感", "迅捷", "血腥", "坚硬", "狡黠", "精锐", "一般", "羸弱"]
        which_2 = {"普通": 35, "精英": 20, "王者": 12, "深渊": 7, "地狱": 5, "猩红": 5, "腐化": 5, "神圣": 5, "黄金": 3, "璀璨": 2, "梦幻": 1}


        if which == "随机小":
            front = random.choice(which_1)
        elif which == "随机大":
            front = random.choices(list(which_2.keys()), weights=list(which_2.values()))[0]
        else:
            front = which

        if "一转" in data:
            item["一转"] = data["一转"]
        item["力量"]["最终"] = (data["力量"]["基础"] + data["力量"]["成长"] * monster_level) * random.uniform(0.9, 1.1) * (0.9 + 0.1 * player_people_number)
        item["智力"]["最终"] = (data["智力"]["基础"] + data["智力"]["成长"] * monster_level) * random.uniform(0.9, 1.1) * (0.9 + 0.1 * player_people_number)
        item["体质"]["最终"] = (data["体质"]["基础"] + data["体质"]["成长"] * monster_level) * random.uniform(0.9, 1.1) * (0.9 + 0.1 * player_people_number)
        item["敏捷"]["最终"] = (data["敏捷"]["基础"] + data["敏捷"]["成长"] * monster_level) * random.uniform(0.9, 1.1) * (0.9 + 0.1 * player_people_number)
        item["力量"]["加点"] = math.ceil(data["力量"]["成长"] * monster_level)
        item["智力"]["加点"] = math.ceil(data["智力"]["成长"] * monster_level)
        item["体质"]["加点"] = math.ceil(data["体质"]["成长"] * monster_level)
        item["敏捷"]["加点"] = math.ceil(data["敏捷"]["成长"] * monster_level)

        
        att_a = sum(range(1, math.ceil(data["力量"].get("强度", 0) * 5) + 1))
        att_b = sum(range(1, math.ceil(data["力量"].get("强度", 0) * 5) + 1))
        att_c = sum(range(1, math.ceil(data["力量"].get("强度", 0) * 5) + 1))
        att_d = sum(range(1, math.ceil(data["力量"].get("强度", 0) * 5) + 1))
        item["力量"]["最终"] = (item["力量"]["最终"] + data["力量"].get("强度", 0) * monster_level + att_a) * (100 + att_a * 5) / 100
        item["智力"]["最终"] = (item["智力"]["最终"] + data["智力"].get("强度", 0) * monster_level + att_b) * (100 + att_b * 5) / 100
        item["体质"]["最终"] = (item["体质"]["最终"] + data["体质"].get("强度", 0) * monster_level + att_c) * (100 + att_c * 5) / 100
        item["敏捷"]["最终"] = (item["敏捷"]["最终"] + data["敏捷"].get("强度", 0) * monster_level + att_d) * (100 + att_d * 5) / 100

        if "一转" in item:
            if item["一转"] == "盾守":
                att_to = item["敏捷"]["最终"] * 0.75 + item["智力"]["最终"] * 0.75
                item["敏捷"]["最终"] *= 0.25
                item["智力"]["最终"] *= 0.25
                item["体质"]["最终"] += att_to * 1
            elif item["一转"] == "战士":
                att_to = item["智力"]["最终"] * 0.75
                item["智力"]["最终"] *= 0.25
                item["力量"]["最终"] += att_to * 0.5
                item["敏捷"]["最终"] += att_to * 0.5
            elif item["一转"] == "法师":
                att_to = item["体质"]["最终"] * 0.75 + item["力量"]["最终"] * 0.75
                item["体质"]["最终"] *= 0.25
                item["力量"]["最终"] *= 0.25
                item["智力"]["最终"] += att_to * 1
            elif item["一转"] == "牧师":
                att_to = item["力量"]["最终"] * 0.75 + item["敏捷"]["最终"] * 0.75
                item["力量"]["最终"] *= 0.25
                item["敏捷"]["最终"] *= 0.25
                item["智力"]["最终"] += att_to * 0.5
                item["体质"]["最终"] += att_to * 0.5
            elif item["一转"] == "刺客":
                att_to = item["体质"]["最终"] * 0.75
                item["体质"]["最终"] *= 0.25
                item["敏捷"]["最终"] += att_to * 1

        if front == "大力" or front == "全能":
            item["力量"]["最终"] += monster_level * 1
            item["力量"]["最终"] *= 1.25
        if front == "神力" or front == "超能":
            item["力量"]["最终"] += monster_level * 2
            item["力量"]["最终"] *= 1.5
        if front == "聪明" or front == "全能":
            item["智力"]["最终"] += monster_level * 1
            item["智力"]["最终"] *= 1.25
        if front == "聪慧" or front == "超能":
            item["智力"]["最终"] += monster_level * 2
            item["智力"]["最终"] *= 1.5
        if front == "强壮" or front == "全能":
            item["体质"]["最终"] += monster_level * 1
            item["体质"]["最终"] *= 1.25
        if front == "强健" or front == "超能":
            item["体质"]["最终"] += monster_level * 2
            item["体质"]["最终"] *= 1.5
        if front == "灵活" or front == "全能":
            item["敏捷"]["最终"] += monster_level * 1
            item["敏捷"]["最终"] *= 1.25
        if front == "灵巧" or front == "超能":
            item["敏捷"]["最终"] += monster_level * 2
            item["敏捷"]["最终"] *= 1.5

        item["力量"]["最终"] = math.ceil(item["力量"]["最终"])
        item["智力"]["最终"] = math.ceil(item["智力"]["最终"])
        item["体质"]["最终"] = math.ceil(item["体质"]["最终"])
        item["敏捷"]["最终"] = math.ceil(item["敏捷"]["最终"])



        item["生命"]["基础最大"] = math.ceil((item["体质"]["最终"] * 60 + item["力量"]["最终"] * 50 + item["智力"]["最终"] * 30 + item["敏捷"]["最终"] * 30) * random.uniform(0.9, 1.1))
        item["魔力"]["基础最大"] = math.ceil((item["体质"]["最终"] * 50 + item["力量"]["最终"] * 30 + item["智力"]["最终"] * 70 + item["敏捷"]["最终"] * 20) * random.uniform(0.9, 1.1))
        item["物攻"]["基础"] = math.ceil((item["体质"]["最终"] * 1 + item["力量"]["最终"] * 8 + item["智力"]["最终"] * 0 + item["敏捷"]["最终"] * 8) * random.uniform(0.9, 1.1))
        item["魔攻"]["基础"] = math.ceil((item["体质"]["最终"] * 1 + item["力量"]["最终"] * 0 + item["智力"]["最终"] * 8 + item["敏捷"]["最终"] * 8) * random.uniform(0.9, 1.1))
        item["物防"]["基础"] = math.ceil((item["体质"]["最终"] * 8 + item["力量"]["最终"] * 5 + item["智力"]["最终"] * 0 + item["敏捷"]["最终"] * 2) * random.uniform(0.9, 1.1))
        item["魔防"]["基础"] = math.ceil((item["体质"]["最终"] * 4 + item["力量"]["最终"] * 2 + item["智力"]["最终"] * 7 + item["敏捷"]["最终"] * 2) * random.uniform(0.9, 1.1))
        item["命中"]["基础"] = math.ceil((item["体质"]["最终"] * 0 + item["力量"]["最终"] * 3 + item["智力"]["最终"] * 3 + item["敏捷"]["最终"] * 8) * random.uniform(0.9, 1.1))
        item["闪避"]["基础"] = math.ceil((item["体质"]["最终"] * 4 + item["力量"]["最终"] * 1 + item["智力"]["最终"] * 1 + item["敏捷"]["最终"] * 8) * random.uniform(0.9, 1.1))
        item["暴击"]["基础"] = math.ceil((item["体质"]["最终"] * 0 + item["力量"]["最终"] * 8 + item["智力"]["最终"] * 1 + item["敏捷"]["最终"] * 5) * random.uniform(0.9, 1.1))
        item["暴免"]["基础"] = math.ceil((item["体质"]["最终"] * 8 + item["力量"]["最终"] * 1 + item["智力"]["最终"] * 5 + item["敏捷"]["最终"] * 0) * random.uniform(0.9, 1.1))
        item["暴伤"]["基础"] = math.ceil((item["体质"]["最终"] * 0 + item["力量"]["最终"] * 1 + item["智力"]["最终"] * 8 + item["敏捷"]["最终"] * 5) * random.uniform(0.9, 1.1))
        item["暴抗"]["基础"] = math.ceil((item["体质"]["最终"] * 8 + item["力量"]["最终"] * 5 + item["智力"]["最终"] * 1 + item["敏捷"]["最终"] * 0) * random.uniform(0.9, 1.1))
        item["韧性"]["基础"] = math.ceil((item["体质"]["最终"] * 6 + item["力量"]["最终"] * 2 + item["智力"]["最终"] * 4 + item["敏捷"]["最终"] * 0) * random.uniform(0.9, 1.1))
        item["速度"]["基础"] = math.ceil((item["体质"]["最终"] * 2 + item["力量"]["最终"] * 2 + item["智力"]["最终"] * 2 + item["敏捷"]["最终"] * 8) * random.uniform(0.9, 1.1))

        """
        转职计算
        """
        x1 = 0
        for i in range(int(item["体质"]["加点"])):
            x1 += 0.95 ** i
        x2 = 0
        for i in range(int(item["力量"]["加点"])):
            x2 += 0.95 ** i
        x3 = 0
        for i in range(int(item["智力"]["加点"])):
            x3 += 0.95 ** i
        x4 = 0
        for i in range(int(item["敏捷"]["加点"])):
            x4 += 0.95 ** i
        if "一转" in item:
            if item["一转"] == "盾守":
                item["物防"]["基础"] += (x1 * 20 + x2 * 40 + x3 * 0 + x4 * 10)
                item["魔防"]["基础"] += (x1 * 20 + x2 * 0 + x3 * 40 + x4 * 10)
                item["暴免"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 80 + x4 * 0)
                item["暴抗"]["基础"] += (x1 * 0 + x2 * 80 + x3 * 0 + x4 * 0)
                item["生命"]["基础最大"] += (x1 * 120 + x2 * 40 + x3 * 40 + x4 * 40)
                item["魔力"]["基础最大"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 20)
                item["命中"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 40)
                item["暴击"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 40)
                item["暴伤"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 40)
            elif item["一转"] == "战士":
                item["生命"]["基础最大"] += (x1 * 120 + x2 * 80 + x3 * 0 + x4 * 0)
                item["魔力"]["基础最大"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 0)
                item["物攻"]["基础"] += (x1 * 0 + x2 * 20 + x3 * 0 + x4 * 0)
                item["物防"]["基础"] += (x1 * 20 + x2 * 20 + x3 * 0 + x4 * 0)
                item["魔防"]["基础"] += (x1 * 10 + x2 * 0 + x3 * 0 + x4 * 0)
                item["命中"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 40)
                item["暴击"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 90 + x4 * 40)
                item["暴伤"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 90 + x4 * 40)
            elif item["一转"] == "法师":
                item["生命"]["基础最大"] += (x1 * 80 + x2 * 0 + x3 * 0 + x4 * 0)
                item["魔力"]["基础最大"] += (x1 * 20 + x2 * 0 + x3 * 120 + x4 * 0)
                item["魔攻"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 20 + x4 * 0)
                item["物防"]["基础"] += (x1 * 10 + x2 * 0 + x3 * 0 + x4 * 0)
                item["魔防"]["基础"] += (x1 * 25 + x2 * 0 + x3 * 10 + x4 * 0)
                item["暴击"]["基础"] += (x1 * 0 + x2 * 90 + x3 * 0 + x4 * 40)
                item["暴伤"]["基础"] += (x1 * 0 + x2 * 90 + x3 * 0 + x4 * 40)
                item["命中"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 40)
            elif item["一转"] == "牧师":
                item["生命"]["基础最大"] += (x1 * 80 + x2 * 40 + x3 * 0 + x4 * 0)
                item["魔力"]["基础最大"] += (x1 * 0 + x2 * 0 + x3 * 40 + x4 * 0)
                item["物防"]["基础"] += (x1 * 20 + x2 * 20 + x3 * 0 + x4 * 0)
                item["魔防"]["基础"] += (x1 * 20 + x2 * 0 + x3 * 20 + x4 * 0)
                item["暴击"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 30)
                item["暴伤"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 30)
                item["物攻"]["基础"] += (x1 * 0 + x2 * 10 + x3 * 0 + x4 * 0)
                item["魔攻"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 10 + x4 * 0)
                item["命中"]["基础"] += (x1 * 0 + x2 * 20 + x3 * 20 + x4 * 30)
                item["闪避"]["基础"] += (x1 * 0 + x2 * 20 + x3 * 20 + x4 * 30)
            elif item["一转"] == "刺客":
                item["生命"]["基础最大"] += (x1 * 80 + x2 * 40 + x3 * 0 + x4 * 0)
                item["魔力"]["基础最大"] += (x1 * 0 + x2 * 0 + x3 * 40 + x4 * 0)
                item["物防"]["基础"] += (x1 * 0 + x2 * 10 + x3 * 0 + x4 * 0)
                item["魔防"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 10 + x4 * 0)
                item["暴免"]["基础"] += (x1 * 40 + x2 * 0 + x3 * 0 + x4 * 0)
                item["暴抗"]["基础"] += (x1 * 40 + x2 * 0 + x3 * 0 + x4 * 0)
                item["物攻"]["基础"] += (x1 * 0 + x2 * 10 + x3 * 0 + x4 * 0)
                item["魔攻"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 10 + x4 * 0)
                item["暴击"]["基础"] += (x1 * 0 + x2 * 30 + x3 * 30 + x4 * 0)
                item["暴伤"]["基础"] += (x1 * 0 + x2 * 30 + x3 * 30 + x4 * 0)
                item["命中"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 60)
                item["闪避"]["基础"] += (x1 * 0 + x2 * 0 + x3 * 0 + x4 * 60)

        item["物理减伤"] = 0
        item["魔法减伤"] = 0
        item["物理增伤"] = 0
        item["魔法增伤"] = 0
        item["生命回复"] = 0
        item["魔力回复"] = 0
        item["最低命中率"] = 0
        item["最低闪避率"] = 0
        item["最低暴击率"] = 0
        item["物理穿透"] = 0
        item["魔法穿透"] = 0
        if "额外" in data:
            item["生命"]["基础最大"] += data["额外"].get("最大生命", 0)
            item["魔力"]["基础最大"] += data["额外"].get("最大魔力", 0)
            item["物攻"]["基础"] += data["额外"].get("物攻", 0)
            item["魔攻"]["基础"] += data["额外"].get("魔攻", 0)
            item["物防"]["基础"] += data["额外"].get("物防", 0)
            item["魔防"]["基础"] += data["额外"].get("魔防", 0)
            item["命中"]["基础"] += data["额外"].get("命中", 0)
            item["闪避"]["基础"] += data["额外"].get("闪避", 0)
            item["暴击"]["基础"] += data["额外"].get("暴击", 0)
            item["暴免"]["基础"] += data["额外"].get("暴免", 0)
            item["暴伤"]["基础"] += data["额外"].get("暴伤", 0)
            item["暴抗"]["基础"] += data["额外"].get("暴抗", 0)
            item["韧性"]["基础"] += data["额外"].get("韧性", 0)
            item["速度"]["基础"] += data["额外"].get("速度", 0)
            item["物理减伤"] = data["额外"].get("物理减伤", 0)
            item["魔法减伤"] = data["额外"].get("魔法减伤", 0)
            item["物理增伤"] = data["额外"].get("物理增伤", 0)
            item["魔法增伤"] = data["额外"].get("魔法增伤", 0)
            item["物理穿透"] = data["额外"].get("物理穿透", 0)
            item["魔法穿透"] = data["额外"].get("魔法穿透", 0)
            item["生命回复"] = data["额外"].get("生命回复", 0)
            item["魔力回复"] = data["额外"].get("魔力回复", 0)
            item["最低命中率"] = data["额外"].get("最低命中率", 0)
            item["最低闪避率"] = data["额外"].get("最低闪避率", 0)
            item["最低暴击率"] = data["额外"].get("最低暴击率", 0)

        if front == "羸弱":
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 1.5)
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 1.5)
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 0.75)
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 0.75)
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 0.75)
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 0.75)
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 0.75)
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 0.75)
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 0.75)
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 0.75)
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 0.75)
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 0.75)
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 0.75)
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 0.75)
        if front == "庞大":
            item["物防"]["基础"] += monster_level * 25
            item["魔防"]["基础"] += monster_level * 25
            item["生命"]["基础最大"] += monster_level * 100
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 2.5)
            item["魔力"]["基础最大"] += monster_level * 100
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 2.5)
        if front == "犀利":
            item["命中"]["基础"] += monster_level * 50
            item["物攻"]["基础"] += monster_level * 25
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 1.5)
            item["魔攻"]["基础"] += monster_level * 25
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 1.5)
        if front == "胆小":
            item["生命"]["基础最大"] += monster_level * 100
            item["物防"]["基础"] += monster_level * 25
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 1.5)
            item["魔防"]["基础"] += monster_level * 25
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 1.5)
        if front == "精明":
            item["闪避"]["基础"] += monster_level * 50
            item["速度"]["基础"] += monster_level * 50
            item["命中"]["基础"] += monster_level * 50
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 2)
        if front == "谨慎":
            item["暴免"]["基础"] += monster_level * 50
            item["暴抗"]["基础"] += monster_level * 50
            item["闪避"]["基础"] += monster_level * 50
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 2)
        if front == "狠毒":
            item["命中"]["基础"] += monster_level * 50
            item["暴击"]["基础"] += monster_level * 50
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 2)
            item["暴伤"]["基础"] += monster_level * 50
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 2)
        if front == "稳重":
            item["物防"]["基础"] += monster_level * 25
            item["魔防"]["基础"] += monster_level * 25
            item["暴免"]["基础"] += monster_level * 50
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 2)
            item["暴抗"]["基础"] += monster_level * 50
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 2)
        if front == "无感":
            item["生命"]["基础最大"] += monster_level * 100
            item["暴免"]["基础"] += monster_level * 50
            item["暴抗"]["基础"] += monster_level * 50
            item["韧性"]["基础"] += monster_level * 50
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 2)
        if front == "迅捷":
            item["命中"]["基础"] += monster_level * 50
            item["闪避"]["基础"] += monster_level * 50
            item["速度"]["基础"] += monster_level * 50
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 2)
        if front == "血腥":
            item["命中"]["基础"] += monster_level * 50
            item["物攻"]["基础"] += monster_level * 25
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 1.5)
            item["魔攻"]["基础"] += monster_level * 25
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 1.5)
            item["暴击"]["基础"] += monster_level * 50
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 2)
            item["暴伤"]["基础"] += monster_level * 50
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 2)
        if front == "坚硬":
            item["生命"]["基础最大"] += monster_level * 100
            item["物防"]["基础"] += monster_level * 25
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 1.5)
            item["魔防"]["基础"] += monster_level * 25
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 1.5)
            item["暴免"]["基础"] += monster_level * 50
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 4)
            item["暴抗"]["基础"] += monster_level * 50
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 4)
        if front == "狡黠":
            item["物攻"]["基础"] += monster_level * 25
            item["魔攻"]["基础"] += monster_level * 25
            item["命中"]["基础"] += monster_level * 50
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 4)
            item["闪避"]["基础"] += monster_level * 50
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 4)
            item["速度"]["基础"] += monster_level * 50
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 4)
            item["韧性"]["基础"] += monster_level * 50
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 2)
        if front == "精锐":
            item["生命"]["基础最大"] += monster_level * 100
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 2.5)
            item["魔力"]["基础最大"] += monster_level * 100
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 2.5)
            item["物攻"]["基础"] += monster_level * 25
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 1.5)
            item["魔攻"]["基础"] += monster_level * 25
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 1.5)
            item["物防"]["基础"] += monster_level * 25
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 1.5)
            item["魔防"]["基础"] += monster_level * 25
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 1.5)
            item["命中"]["基础"] += monster_level * 50
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 2)
            item["闪避"]["基础"] += monster_level * 50
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 2)
            item["暴击"]["基础"] += monster_level * 50
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 2)
            item["暴伤"]["基础"] += monster_level * 50
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 2)
            item["暴免"]["基础"] += monster_level * 50
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 2)
            item["暴抗"]["基础"] += monster_level * 50
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 2)
            item["速度"]["基础"] += monster_level * 50
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 2)
            item["韧性"]["基础"] += monster_level * 50
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 2)
        if front == "精英":
            item["生命"]["基础最大"] += monster_level * 20
            item["魔力"]["基础最大"] += monster_level * 20
            item["物攻"]["基础"] += monster_level * 5
            item["魔攻"]["基础"] += monster_level * 5
            item["物防"]["基础"] += monster_level * 5
            item["魔防"]["基础"] += monster_level * 5
            item["命中"]["基础"] += monster_level * 10
            item["闪避"]["基础"] += monster_level * 10
            item["暴击"]["基础"] += monster_level * 10
            item["暴伤"]["基础"] += monster_level * 10
            item["暴免"]["基础"] += monster_level * 10
            item["暴抗"]["基础"] += monster_level * 10
            item["速度"]["基础"] += monster_level * 10
            item["韧性"]["基础"] += monster_level * 10
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 1.4)
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 1.4)
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 1.1)
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 1.1)
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 1.1)
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 1.1)
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 1.2)
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 1.2)
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 1.2)
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 1.2)
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 1.2)
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 1.2)
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 1.2)
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 1.2)
        if front == "王者":
            item["生命"]["基础最大"] += monster_level * 40
            item["魔力"]["基础最大"] += monster_level * 40
            item["物攻"]["基础"] += monster_level * 10
            item["魔攻"]["基础"] += monster_level * 10
            item["物防"]["基础"] += monster_level * 10
            item["魔防"]["基础"] += monster_level * 10
            item["命中"]["基础"] += monster_level * 20
            item["闪避"]["基础"] += monster_level * 20
            item["暴击"]["基础"] += monster_level * 20
            item["暴伤"]["基础"] += monster_level * 20
            item["暴免"]["基础"] += monster_level * 20
            item["暴抗"]["基础"] += monster_level * 20
            item["速度"]["基础"] += monster_level * 20
            item["韧性"]["基础"] += monster_level * 20
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 1.8)
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 1.8)
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 1.2)
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 1.2)
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 1.2)
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 1.2)
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 1.4)
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 1.4)
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 1.4)
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 1.4)
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 1.4)
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 1.4)
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 1.4)
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 1.4)
        if front == "深渊":
            item["生命"]["基础最大"] += monster_level * 60
            item["魔力"]["基础最大"] += monster_level * 60
            item["物攻"]["基础"] += monster_level * 15
            item["魔攻"]["基础"] += monster_level * 15
            item["物防"]["基础"] += monster_level * 15
            item["魔防"]["基础"] += monster_level * 15
            item["命中"]["基础"] += monster_level * 30
            item["闪避"]["基础"] += monster_level * 30
            item["暴击"]["基础"] += monster_level * 30
            item["暴伤"]["基础"] += monster_level * 30
            item["暴免"]["基础"] += monster_level * 30
            item["暴抗"]["基础"] += monster_level * 30
            item["速度"]["基础"] += monster_level * 30
            item["韧性"]["基础"] += monster_level * 30
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 2.2)
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 2.2)
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 1.3)
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 1.3)
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 1.3)
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 1.3)
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 1.6)
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 1.6)
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 1.6)
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 1.6)
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 1.6)
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 1.6)
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 1.6)
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 1.6)
        if front == "地狱":
            item["生命"]["基础最大"] += monster_level * 80
            item["魔力"]["基础最大"] += monster_level * 80
            item["物攻"]["基础"] += monster_level * 20
            item["魔攻"]["基础"] += monster_level * 20
            item["物防"]["基础"] += monster_level * 20
            item["魔防"]["基础"] += monster_level * 20
            item["命中"]["基础"] += monster_level * 40
            item["闪避"]["基础"] += monster_level * 40
            item["暴击"]["基础"] += monster_level * 40
            item["暴伤"]["基础"] += monster_level * 40
            item["暴免"]["基础"] += monster_level * 40
            item["暴抗"]["基础"] += monster_level * 40
            item["速度"]["基础"] += monster_level * 40
            item["韧性"]["基础"] += monster_level * 40
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 2.6)
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 2.6)
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 1.4)
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 1.4)
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 1.4)
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 1.4)
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 1.8)
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 1.8)
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 1.8)
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 1.8)
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 1.8)
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 1.8)
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 1.8)
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 1.8)
        if front == "猩红":
            item["生命"]["基础最大"] += monster_level * 100
            item["魔力"]["基础最大"] += monster_level * 100
            item["物攻"]["基础"] += monster_level * 25
            item["魔攻"]["基础"] += monster_level * 25
            item["物防"]["基础"] += monster_level * 25
            item["魔防"]["基础"] += monster_level * 25
            item["命中"]["基础"] += monster_level * 50
            item["闪避"]["基础"] += monster_level * 50
            item["暴击"]["基础"] += monster_level * 50
            item["暴伤"]["基础"] += monster_level * 50
            item["暴免"]["基础"] += monster_level * 50
            item["暴抗"]["基础"] += monster_level * 50
            item["速度"]["基础"] += monster_level * 50
            item["韧性"]["基础"] += monster_level * 50
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 1.8)
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 1.8)
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 1.8)
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 1.8)
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 1.2)
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 1.2)
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 2.6)
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 1.5)
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 2.6)
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 2.6)
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 1.2)
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 1.2)
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 1.5)
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 1.5)
        if front == "神圣":
            item["生命"]["基础最大"] += monster_level * 100
            item["魔力"]["基础最大"] += monster_level * 100
            item["物攻"]["基础"] += monster_level * 25
            item["魔攻"]["基础"] += monster_level * 25
            item["物防"]["基础"] += monster_level * 25
            item["魔防"]["基础"] += monster_level * 25
            item["命中"]["基础"] += monster_level * 50
            item["闪避"]["基础"] += monster_level * 50
            item["暴击"]["基础"] += monster_level * 50
            item["暴伤"]["基础"] += monster_level * 50
            item["暴免"]["基础"] += monster_level * 50
            item["暴抗"]["基础"] += monster_level * 50
            item["速度"]["基础"] += monster_level * 50
            item["韧性"]["基础"] += monster_level * 50
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 2.6)
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 2.6)
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 1.5)
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 1.5)
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 2.6)
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 2.6)
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 2)
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 1.2)
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 1.2)
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 1.2)
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 2.6)
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 2.6)
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 1.5)
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 2.6)
        if front == "腐化":
            item["生命"]["基础最大"] += monster_level * 100
            item["魔力"]["基础最大"] += monster_level * 100
            item["物攻"]["基础"] += monster_level * 25
            item["魔攻"]["基础"] += monster_level * 25
            item["物防"]["基础"] += monster_level * 25
            item["魔防"]["基础"] += monster_level * 25
            item["命中"]["基础"] += monster_level * 50
            item["闪避"]["基础"] += monster_level * 50
            item["暴击"]["基础"] += monster_level * 50
            item["暴伤"]["基础"] += monster_level * 50
            item["暴免"]["基础"] += monster_level * 50
            item["暴抗"]["基础"] += monster_level * 50
            item["速度"]["基础"] += monster_level * 50
            item["韧性"]["基础"] += monster_level * 50
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 4.2)
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 4.2)
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 1.5)
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 1.5)
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 1.2)
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 1.2)
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 2.6)
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 2.6)
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 1.5)
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 1.5)
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 1.5)
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 1.5)
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 1.2)
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 1.2)
        if front == "黄金":
            item["生命"]["基础最大"] += monster_level * 100
            item["魔力"]["基础最大"] += monster_level * 100
            item["物攻"]["基础"] += monster_level * 25
            item["魔攻"]["基础"] += monster_level * 25
            item["物防"]["基础"] += monster_level * 25
            item["魔防"]["基础"] += monster_level * 25
            item["命中"]["基础"] += monster_level * 50
            item["闪避"]["基础"] += monster_level * 50
            item["暴击"]["基础"] += monster_level * 50
            item["暴伤"]["基础"] += monster_level * 50
            item["暴免"]["基础"] += monster_level * 50
            item["暴抗"]["基础"] += monster_level * 50
            item["速度"]["基础"] += monster_level * 50
            item["韧性"]["基础"] += monster_level * 50
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 3)
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 3)
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 1.5)
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 1.5)
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 2)
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 2)
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 4)
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 2)
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 2)
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 2)
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 2)
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 2)
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 2)
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 2)
        if front == "璀璨":
            item["生命"]["基础最大"] += monster_level * 100
            item["魔力"]["基础最大"] += monster_level * 100
            item["物攻"]["基础"] += monster_level * 25
            item["魔攻"]["基础"] += monster_level * 25
            item["物防"]["基础"] += monster_level * 25
            item["魔防"]["基础"] += monster_level * 25
            item["命中"]["基础"] += monster_level * 50
            item["闪避"]["基础"] += monster_level * 50
            item["暴击"]["基础"] += monster_level * 50
            item["暴伤"]["基础"] += monster_level * 50
            item["暴免"]["基础"] += monster_level * 50
            item["暴抗"]["基础"] += monster_level * 50
            item["速度"]["基础"] += monster_level * 50
            item["韧性"]["基础"] += monster_level * 50
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 4)
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 4)
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 1.7)
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 1.7)
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 2.5)
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 2.5)
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 8)
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 2.5)
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 2.5)
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 2.5)
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 2.5)
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 2.5)
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 2.5)
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 2.5)
        if front == "梦幻":
            item["生命"]["基础最大"] += monster_level * 100
            item["魔力"]["基础最大"] += monster_level * 100
            item["物攻"]["基础"] += monster_level * 25
            item["魔攻"]["基础"] += monster_level * 25
            item["物防"]["基础"] += monster_level * 25
            item["魔防"]["基础"] += monster_level * 25
            item["命中"]["基础"] += monster_level * 50
            item["闪避"]["基础"] += monster_level * 50
            item["暴击"]["基础"] += monster_level * 50
            item["暴伤"]["基础"] += monster_level * 50
            item["暴免"]["基础"] += monster_level * 50
            item["暴抗"]["基础"] += monster_level * 50
            item["速度"]["基础"] += monster_level * 50
            item["韧性"]["基础"] += monster_level * 50
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 5)
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 5)
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 2)
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 2)
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 4)
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 4)
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 12)
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 4)
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 4)
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 4)
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 4)
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 4)
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 4)
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 4)

        if front == "标准":
            item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * 1)
            item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"] * 1)
            item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"] * 1)
            item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"] * 1)
            item["物防"]["基础"] = math.ceil(item["物防"]["基础"] * 1)
            item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"] * 1)
            item["命中"]["基础"] = math.ceil(item["命中"]["基础"] * 1)
            item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"] * 1)
            item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"] * 1)
            item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"] * 1)
            item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"] * 1)
            item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"] * 1)
            item["速度"]["基础"] = math.ceil(item["速度"]["基础"] * 1)
            item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"] * 1)


        item["生命"]["基础最大"] = math.ceil(item["生命"]["基础最大"] * (0.2 + player_people_number * 0.8))
        item["魔力"]["基础最大"] = math.ceil(item["魔力"]["基础最大"])
        item["物攻"]["基础"] = math.ceil(item["物攻"]["基础"])
        item["魔攻"]["基础"] = math.ceil(item["魔攻"]["基础"])
        item["物防"]["基础"] = math.ceil(item["物防"]["基础"])
        item["魔防"]["基础"] = math.ceil(item["魔防"]["基础"])
        item["命中"]["基础"] = math.ceil(item["命中"]["基础"])
        item["闪避"]["基础"] = math.ceil(item["闪避"]["基础"])
        item["暴击"]["基础"] = math.ceil(item["暴击"]["基础"])
        item["暴伤"]["基础"] = math.ceil(item["暴伤"]["基础"])
        item["暴免"]["基础"] = math.ceil(item["暴免"]["基础"])
        item["暴抗"]["基础"] = math.ceil(item["暴抗"]["基础"])
        item["速度"]["基础"] = math.ceil(item["速度"]["基础"])
        item["韧性"]["基础"] = math.ceil(item["韧性"]["基础"])


        uid = 0
        nickname = "{}的 {}".format(front, monster_name)
        str0 = item["力量"]["最终"]
        int0 = item["智力"]["最终"]
        vit0 = item["体质"]["最终"]
        agi0 = item["敏捷"]["最终"]
        hp = item["生命"]
        mp = item["魔力"]
        attack = item["物攻"]
        magic_attack = item["魔攻"]
        defend = item["物防"]
        magic_defend = item["魔防"]
        hit = item["命中"]
        avoid = item["闪避"]
        crit = item["暴击"]
        crit_resist = item["暴免"]
        crit_harm = item["暴伤"]
        crit_harm_resist = item["暴抗"]
        tough = item["韧性"]
        speed = item["速度"]
        hp["当前最大"] = hp["基础最大"]
        mp["当前最大"] = mp["基础最大"]
        hp["当前"] = hp["基础最大"]
        mp["当前"] = mp["基础最大"]
        attack["当前"] = attack["基础"]
        magic_attack["当前"] = magic_attack["基础"]
        defend["当前"] = defend["基础"]
        magic_defend["当前"] = magic_defend["基础"]
        hit["当前"] = hit["基础"]
        avoid["当前"] = avoid["基础"]
        crit["当前"] = crit["基础"]
        crit_resist["当前"] = crit_resist["基础"]
        crit_harm["当前"] = crit_harm["基础"]
        crit_harm_resist["当前"] = crit_harm_resist["基础"]
        tough["当前"] = tough["基础"]
        speed["当前"] = speed["基础"]
        skills = data["技能"]
        equipped_skills = []
        effect = []
        for i in range(1, skills["数量"]+1):
            skill = skills[f"技能{i}"]
            if skill:
                equipped_skills.append(skill)
        if "被动" in data:
            for every_list in data["被动"]:
                if every_list["名称"] == "其行如风":
                    item["最低命中率"] = 50
                if every_list["名称"] == "假死替身":
                    item["最低闪避率"] = 50
                effect.append(every_list)
        battle_list["敌人"].append({"uid": uid, "昵称": nickname, "等级": monster_level, "一转": item["一转"], "力量": str0, "智力": int0, "体质": vit0, "敏捷": agi0, "生命": hp, "魔力": mp, "物攻": attack, "魔攻": magic_attack, "物防": defend, "魔防": magic_defend, "命中": hit, "闪避": avoid, "暴击": crit, "暴免": crit_resist, "暴伤": crit_harm, "暴抗": crit_harm_resist, "韧性": tough, "速度": speed, "最低命中率": {"基础": item["最低命中率"], "当前": item["最低命中率"]}, "最低闪避率": {"基础": item["最低闪避率"], "当前": item["最低闪避率"]}, "最低暴击率": {"基础": item["最低暴击率"], "当前": item["最低暴击率"]}, "物理增伤": {"基础": item["物理增伤"], "当前": item["物理增伤"]}, "魔法增伤": {"基础": item["魔法增伤"], "当前": item["魔法增伤"]}, "物理减伤": {"基础": item["物理减伤"], "当前": item["物理减伤"]}, "魔法减伤": {"基础": item["魔法减伤"], "当前": item["魔法减伤"]}, "物理穿透": {"基础": item["物理穿透"], "当前": item["物理穿透"]}, "魔法穿透": {"基础": item["魔法穿透"], "当前": item["魔法穿透"]}, "生命回复": {"基础": item["生命回复"], "当前": item["生命回复"]}, "魔力回复": {"基础": item["魔力回复"], "当前": item["魔力回复"]}, "累计伤害": 0, "累计承伤": 0, "技能": equipped_skills, "掉落": data["掉落"],  "经验": data["经验"], "效果": effect, "计数器": {"阶段": 1}})

    with open(f"data/battle/{id}.txt", 'w') as f:
        json.dump(battle_list, f, ensure_ascii=False, indent=4)
    all_auto = True
    with open(f"data/battle/{id}.txt", 'r') as f:
        data = json.load(f)
        bt_round = data["回合"]
        for item in data["玩家"]:
            if item.get("自动战斗", "否") == "否":
                all_auto = False
            else:
                auto_skills = item["自动战斗顺序"].split("-")
                auto_total = len(auto_skills)
                now_skill_num = int(bt_round) % int(auto_total)
                if now_skill_num == 0:
                    now_skill_num = int(auto_total)
                now_skill = auto_skills[now_skill_num - 1]
                if int(now_skill) <= len(item["技能"]):
                    if now_skill == "0":
                        item["出招"] = "普攻"
                    else:
                        item["出招"] = "技能{}".format(now_skill)
                else:
                    item["出招"] = "普攻"
    with open(f"data/battle/{id}.txt", 'w') as f:
        json.dump(data, f, ensure_ascii=False, indent=4)
    if all_auto:
        message.content = ""
        txt = await battle_round(message)
        await send_message(message, 0, 2, txt)
        return  


async def search_battle(openid):
    id = await player_id(openid)
    battle_id = id
    with open("data/team.txt", 'r') as f:
        team = json.load(f)
        group = []
        for item in team:
            if id in item["成员"]:
                group = item["成员"]
        for uid in group:
            if os.path.exists(f"data/battle/{uid}.txt"):
                battle_id = uid
            break
    return battle_id


async def battle_view(message):
    if hasattr(message.author, 'member_openid'):
        number = message.author.member_openid 
    elif hasattr(message.author, 'user_openid'):    
        number = message.author.user_openid
    battle_id = await search_battle(number)
    with open(f"data/battle/{battle_id}.txt", 'r') as f:
        data = json.load(f)
        txt = ""
        for player in data["玩家"]:
            bar_length = 10
            filled_length = int(round(bar_length * player["生命"]["当前"] / float(player["生命"]["当前最大"])))
            hp_bar = u"\u2588" * filled_length + u"\u2591" * (bar_length - filled_length)
            filled_length = int(round(bar_length * player["魔力"]["当前"] / float(player["魔力"]["当前最大"])))
            mp_bar = u"\u2588" * filled_length + u"\u2591" * (bar_length - filled_length)
            effect_txt = "【状态】："
            for effect in player["效果"]:
                if effect["类型"] == "光环":
                    effect_txt += "\n[光环]#{}#".format(effect["名称"])
            for effect in player["效果"]:
                if effect["类型"] == "控制":
                    effect_txt += "\n[控制]({}){}中。。。".format(effect["回合"], effect["属性"])
            for effect in player["效果"]:
                if effect["名称"] == "黎明" and effect["类型"] == "装备":
                    effect_txt += "\n[黎明]来自黎明的祝福({})".format(effect["层数"])
            for effect in player["效果"]:
                if effect["名称"] == "诅咒" and effect["类型"] == "被装备":
                    effect_txt += "\n[诅咒]来自未知的诅咒({})".format(effect["层数"])
            for effect in player["效果"]:
                if effect["名称"] == "撕裂" and effect["类型"] == "被装备":
                    effect_txt += "\n[撕裂]魔狼的利刃({})".format(effect["层数"])
            for effect in player["效果"]:
                if effect["类型"] == "获得":
                    effect_txt += "\n[效果]({})获得{}%{}".format(effect["回合"], effect["数值"], effect["属性"])
            for effect in player["效果"]:
                if effect["类型"] == "增益":
                    effect_txt += "\n[↑↑]({}){}提升{}%".format(effect["回合"], effect["属性"], effect["数值"])
            for effect in player["效果"]:
                if effect["类型"] == "减益":
                    effect_txt += "\n[↓↓]({}){}降低{}%".format(effect["回合"], effect["属性"], effect["数值"])
            for effect in player["效果"]:
                if effect["类型"] == "流失":
                    if effect["属性"] == "最大生命百分比" or effect["属性"] == "当前生命百分比":
                        effect_txt += "\n[流失]({})每回合减少{}%{}".format(effect["回合"], effect["数值"], effect["属性"])
                    elif effect["属性"] == "固定生命值":
                        effect_txt += "\n[流失]({})每回合减少{}{}".format(effect["回合"], effect["数值"], effect["属性"])


            player_txt = "\n【{}】Lv.{}\n[生命]{}\n{}/{}\n[魔力]{}\n{}/{}\n[物攻]{}  [魔攻]{}\n[物防]{}  [魔防]{}\n[命中]{}  [闪避]{}\n[暴击]{}  [暴免]{}\n[暴伤]{}  [暴抗]{}\n[韧性]{}  [速度]{}\n[物增]{}  [魔增]{}\n[物减]{}  [魔减]{}\n[回血]{}  [回蓝]{}\n{}\n————————————".format(player["昵称"], player["等级"], hp_bar, player["生命"]["当前"], player["生命"]["当前最大"], mp_bar, player["魔力"]["当前"], player["魔力"]["当前最大"], player["物攻"]["当前"], player["魔攻"]["当前"], player["物防"]["当前"], player["魔防"]["当前"], player["命中"]["当前"], player["闪避"]["当前"], player["暴击"]["当前"], player["暴免"]["当前"], player["暴伤"]["当前"], player["暴抗"]["当前"], player["韧性"]["当前"], player["速度"]["当前"], player["物理增伤"]["当前"], player["魔法增伤"]["当前"], player["物理减伤"]["当前"], player["魔法减伤"]["当前"], player["生命回复"]["当前"], player["魔力回复"]["当前"], effect_txt)
            txt += player_txt
        for player in data["敌人"]:
            skill_txt = ""
            bar_length = 10
            filled_length = int(round(bar_length * player["生命"]["当前"] / float(player["生命"]["当前最大"])))
            hp_bar = u"\u2588" * filled_length + u"\u2591" * (bar_length - filled_length)
            filled_length = int(round(bar_length * player["魔力"]["当前"] / float(player["魔力"]["当前最大"])))
            mp_bar = u"\u2588" * filled_length + u"\u2591" * (bar_length - filled_length)
            for skill in player["技能"]:
                skill_txt += "[{}]Lv.{} ".format(skill["名称"], skill["等级"])
            effect_txt = "【状态】："
            for effect in player["效果"]:
                if effect["类型"] == "光环":
                    effect_txt += "\n[光环]#{}#".format(effect["名称"])
            for effect in player["效果"]:
                if effect["类型"] == "控制":
                    effect_txt += "\n[控制]({}){}中。。。".format(effect["回合"], effect["属性"])
            for effect in player["效果"]:
                if effect["名称"] == "诅咒" and effect["类型"] == "被装备":
                    effect_txt += "\n[诅咒]来自未知的诅咒({})".format(effect["层数"])
            for effect in player["效果"]:
                if effect["名称"] == "撕裂" and effect["类型"] == "被装备":
                    effect_txt += "\n[撕裂]魔狼的利刃({})".format(effect["层数"])
            for effect in player["效果"]:
                if effect["类型"] == "获得":
                    effect_txt += "\n[效果]({})获得{}%{}".format(effect["回合"], effect["数值"], effect["属性"])
            for effect in player["效果"]:
                if effect["类型"] == "嗜血":
                    effect_txt += "\n[效果]({})获得{}%{}".format(effect["回合"], effect["数值"], "生命汲取")
            for effect in player["效果"]:
                if effect["类型"] == "增益":
                    effect_txt += "\n[↑↑]({}){}提升{}%".format(effect["回合"], effect["属性"], effect["数值"])
            for effect in player["效果"]:
                if effect["类型"] == "减益":
                    effect_txt += "\n[↓↓]({}){}降低{}%".format(effect["回合"], effect["属性"], effect["数值"])
            for effect in player["效果"]:
                if effect["类型"] == "流失":
                    if effect["属性"] == "最大生命百分比" or effect["属性"] == "当前生命百分比":
                        effect_txt += "\n[流失]({})每回合减少{}%{}".format(effect["回合"], effect["数值"], effect["属性"])
                    elif effect["属性"] == "固定生命值":
                        effect_txt += "\n[流失]({})每回合减少{}{}".format(effect["回合"], effect["数值"], effect["属性"])
            player_txt = "\n☠敌人☠【{}】Lv.{}\n[生命]{}\n{}/{}\n[魔力]{}\n{}/{}\n[物攻]{}  [魔攻]{}\n[物防]{}  [魔防]{}\n[命中]{}  [闪避]{}\n[暴击]{}  [暴免]{}\n[暴伤]{}  [暴抗]{}\n[韧性]{}  [速度]{}\n[物增]{}  [魔增]{}\n[物减]{}  [魔减]{}\n[回血]{}  [回蓝]{}\n技能:{}\n{}\n————————————".format(player["昵称"], player["等级"], hp_bar, player["生命"]["当前"], player["生命"]["当前最大"], mp_bar, player["魔力"]["当前"], player["魔力"]["当前最大"], player["物攻"]["当前"], player["魔攻"]["当前"], player["物防"]["当前"], player["魔防"]["当前"], player["命中"]["当前"], player["闪避"]["当前"], player["暴击"]["当前"], player["暴免"]["当前"], player["暴伤"]["当前"], player["暴抗"]["当前"], player["韧性"]["当前"], player["速度"]["当前"], player["物理增伤"]["当前"], player["魔法增伤"]["当前"], player["物理减伤"]["当前"], player["魔法减伤"]["当前"], player["生命回复"]["当前"], player["魔力回复"]["当前"], skill_txt, effect_txt)
            txt += player_txt

    lines = txt.split('\n')
    lines.pop()
    new_txt = '\n'.join(lines)
    
    await send_message(message, 0, 1, new_txt)
    return


async def battle_round(message):
    if hasattr(message.author, 'member_openid'):
        number = message.author.member_openid 
    elif hasattr(message.author, 'user_openid'):    
        number = message.author.user_openid
    txt = ""
    battle_id = await search_battle(number)
    player_uid = await player_id(number)
    with open(f"data/battle/{battle_id}.txt", 'r') as f:
        data = json.load(f)
        for player_data in data["玩家"]:
            if player_data["uid"] == player_uid:
                if "普攻" in message.content:
                    player_data["出招"] = "普攻"
                elif "技能" in message.content:
                    skill_number = int(message.content.split("技能")[1]) - 1
                    if player_data["技能"][skill_number].get("冷却", 0) > 0:
                        txt = "【技能[{}]冷却中！】".format(player_data["技能"][skill_number]["名称"])
                        await send_message(message, 0, 1, txt)
                        return
                    else:
                        player_data["出招"] = message.content
                elif "使用" in message.content:
                    player_data["出招"] = message.content
                break
    
        for player_data in data["玩家"]:
            if player_data.get("二转", "") == "影忍":
                if player_data.get("主人uid", "") != "":
                    if any(in_player_data["类型"] == "强化" and in_player_data["属性"] == "影分身" for in_player_data in player_data["效果"]):
                        for in_player in data["玩家"]:
                            if in_player["uid"] == player_data["主人uid"]:
                                in_player["出招"] = "{}·强化组合技".format(in_player["出招"])
                                player_data["出招"] = "跳过"
                                break
                    else:
                        act_random = random.random()
                        if act_random < 1.1:
                            for in_player in data["玩家"]:
                                if in_player["uid"] == player_data["主人uid"]:
                                    in_player["出招"] = "{}·组合技".format(in_player["出招"])
                                    player_data["出招"] = "跳过"
                                    break
                        else:
                            player_data["出招"] = "技能{}".format(random.randint(0, len(player_data["技能"]) - 1))
                    continue
        
        ready = True
        for player_data in data["玩家"]:
            if player_data.get("主人uid", "") != "":
                continue
            if player_data["出招"] == "":
                ready = False
                txt += "\n【{}】".format(player_data["昵称"])
            else:
                if "技能" in player_data["出招"]:
                    if "·组合技" in player_data["出招"]:
                        skill_num = int((player_data["出招"].split("技能")[1]).split("·组合技")[0])
                    elif "·强化组合技" in player_data["出招"]:
                        skill_num = int((player_data["出招"].split("技能")[1]).split("·强化组合技")[0])
                    else:
                        skill_num = int(player_data["出招"].split("技能")[1])

                    if skill_num <= len(player_data["技能"]):
                        if player_data["技能"][int(skill_num) - 1].get("冷却", 0) > 1:
                            player_data["出招"] = "普攻"
                            skill_show = "普攻"
                        else:
                            skill_show = "技能" + player_data["技能"][int(skill_num) - 1]["名称"]
                    else:
                        player_data["出招"] = "普攻"
                        skill_show = "普攻"
                elif "普攻" in player_data["出招"]:
                    player_data["出招"] = "普攻"
                    skill_show = "普攻"
                elif "使用" in player_data["出招"]:
                    skill_show = player_data["出招"]
                txt += "\n【{}】已就绪！[{}]".format(player_data["昵称"], skill_show)
        with open(f"data/battle/{battle_id}.txt", 'w') as f:
            json.dump(data, f, ensure_ascii=False, indent=4)



        if ready == False:

            await send_message(message, 0, 1, txt)
            return

        
        
        
        
        else:
            bat_round = data["回合"]
            txt = "\n『战斗▸{}◂回合』".format(data["回合"])
        
        #排列先后顺序
    with open(f"data/battle/{battle_id}.txt", 'r') as f:
        data = json.load(f)
        all_entities = data["玩家"] + data["敌人"]
        sorted_entities = sorted(all_entities, key=lambda x: x["速度"]["当前"], reverse=True)
        result = []
        for entity in sorted_entities:
            result.append(entity["uid"])
        
        if_have_titan = False
        if_have_saint = False
        if_titan_share = False
        titan_share_number = 0
        titan_share_uid = []
        titan_uid = []
        saint_uid = []
        for player_job in data["玩家"]:
            if player_job.get("二转", "") == "泰坦":
                if_have_titan = True
                titan_uid.append(player_job["uid"])
                for titan_skill in player_job["效果"]:
                    if titan_skill.get("类型") == "获得" and titan_skill.get("属性") == "队伍承伤":
                        if_titan_share = True
                        titan_share_number = titan_skill["数值"]
                        titan_share_uid.append(player_job["uid"])
                        break

            if player_job.get("二转", "") == "神官":
                if_have_saint = True
                saint_uid.append(player_job["uid"])
             

        for uid in result:
        

            #txt += "\n————————————"
            if uid != 0:

                survivor_final = [sur for sur in data["玩家"] if sur["生命"]["当前"] > 0]
                monster_final = [sur for sur in data["敌人"] if sur["生命"]["当前"] > 0]
                if survivor_final == [] or monster_final == []:
                    break
                for item in data["玩家"]:
                    if item["uid"] == uid:
                        player_data = item
                        break
                
                can_attack = True

                if_shadow = False
                if player_data.get("主人uid", "") != "" and player_data["出招"] == "跳过":
                    can_attack = False


                if player_data["生命"]["当前"] <= 0:
                    txt += "\n【[{}]已丧失战斗能力】".format(player_data["昵称"])
                    survivor_final = [sur for sur in data["玩家"] if sur["生命"]["当前"] > 0]
                    monster_final = [sur for sur in data["敌人"] if sur["生命"]["当前"] > 0]
                    if survivor_final == [] or monster_final == []:
                        break
                    else:
                        continue
                

                """生命魔力回复"""
                if player_data["生命回复"]["当前"] != 0:
                    hp_01 = player_data["生命"]["当前"]
                    hp_up = int(player_data["生命"]["当前最大"] * player_data["生命回复"]["当前"] / 100)
                    hp_level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "不灭意志"] or [0]
                    if hp_level[0] > 0:
                        hp_up = hp_up * (1 + 0.2 * hp_level[0] * (player_data["生命"]["当前最大"] - player_data["生命"]["当前"]) / player_data["生命"]["当前最大"])
                    hp_up = int(hp_up)
                    player_data["生命"]["当前"] += hp_up
                    if player_data["生命"]["当前"] > player_data["生命"]["当前最大"]:
                        player_data["生命"]["当前"] = player_data["生命"]["当前最大"]
                    hp_02 = player_data["生命"]["当前"]
                    txt += "\n[{}]生命({}→{})".format(player_data["昵称"], hp_01, hp_02)
                if player_data["魔力回复"]["当前"] != 0:
                    mp_01 = player_data["魔力"]["当前"]
                    mp_up = int(player_data["魔力"]["当前最大"] * player_data["魔力回复"]["当前"] / 100)
                    player_data["魔力"]["当前"] += mp_up
                    if player_data["魔力"]["当前"] > player_data["魔力"]["当前最大"]:
                        player_data["魔力"]["当前"] = player_data["魔力"]["当前最大"]
                    mp_02 = player_data["魔力"]["当前"]
                    txt += "\n[{}]魔力({}→{})".format(player_data["昵称"], mp_01, mp_02)



                player_status = player_data["效果"]
                if_player_unlimit_combo = False
                player_many_hit = 1
                run_blood_effect = []
                for status1 in player_status:

                    if status1["类型"] == "光环":
                        if status1.get("名称","") == "圣天赐福":
                            if any(in_player_data["生命"]["当前"] > 0 for in_player_data in data["玩家"] if in_player_data["uid"] in saint_uid):

                                txt += "\n⛩️圣天赐福⛩️"
                                if player_data["生命"]["当前"] > 0:

                                    bless_aim_hp1 = math.ceil(player_data["生命"]["当前"])
                                    bless_aim_hp = math.ceil(player_data["生命"]["当前最大"] * 0.05)
                                    bless_aim_hp2 = bless_aim_hp1 + bless_aim_hp
                                    if bless_aim_hp2 > player_data["生命"]["当前最大"]:
                                        bless_aim_hp2 = player_data["生命"]["当前最大"]
                                    player_data["生命"]["当前"] = bless_aim_hp2

                                    bless_aim_mp1 = math.ceil(player_data["魔力"]["当前"])
                                    bless_aim_mp = math.ceil(player_data["魔力"]["当前最大"] * 0.05)
                                    bless_aim_mp2 = bless_aim_mp1 + bless_aim_mp
                                    if bless_aim_mp2 > player_data["魔力"]["当前最大"]:
                                        bless_aim_mp2 = player_data["魔力"]["当前最大"]
                                    player_data["魔力"]["当前"] = bless_aim_mp2

                                    txt += "\n[{}]生命({}→{}) 魔力({}→{})".format(player_data["昵称"], bless_aim_hp1, bless_aim_hp2, bless_aim_mp1, bless_aim_mp2)

                    elif status1["类型"] == "职业":
                        if status1.get("属性","") == "无限连击":
                            if_player_unlimit_combo = True
                            player_unlimit_combo_name = status1["名称"]
                            player_many_hit = 99
                            continue

                    elif status1["类型"] == "装备":
                        if status1["名称"] == "黎明":
                            status1["层数"] += 1
                            txt += "\n✨︎#黎明#[{}]受到祝福".format(player_data["昵称"])
                            if status1["层数"] > 20:
                                status1["层数"] = 20

                        elif status1["名称"] == "诅咒":
                            txt += "\n☠️#诅咒#敌人受到未知的诅咒"
                            for enemy in data["敌人"]:
                                if not any(enemy1["名称"] == status1["名称"] for enemy1 in enemy["效果"]):
                                    enemy["效果"].append({"名称": status1["名称"], "类型": "被装备", "层数": 1, "回合": 999})
                                else:
                                    [enemy1.update({"层数": min(enemy1["层数"] + 1, 20)}) for enemy1 in enemy["效果"] if enemy1["名称"] == status1["名称"]]
                        continue

                    



                    elif status1["类型"] == "特殊":
                        if status1["名称"] == "史史史":
                            random1 = random.randint(1, 100)
                            if random1 <= 25:
                                hp_01 = player_data["生命"]["当前"]
                                player_data["生命"]["当前"] += 66
                                if player_data["生命"]["当前"] > player_data["生命"]["当前最大"]:
                                    player_data["生命"]["当前"] = player_data["生命"]["当前最大"]
                                hp_02 = player_data["生命"]["当前"]
                                txt += "\n♥小史莱姆♥为[{}]恢复了66点生命({}→{})".format(player_data["昵称"], hp_01, hp_02)
                            elif random1 > 25 and random1 <= 50:
                                mp_01 = player_data["魔力"]["当前"]
                                player_data["魔力"]["当前"] += 66
                                if player_data["魔力"]["当前"] > player_data["魔力"]["当前最大"]:
                                    player_data["魔力"]["当前"] = player_data["魔力"]["当前最大"]
                                mp_02 = player_data["魔力"]["当前"]
                                txt += "\n♥小史莱姆♥为[{}]恢复了66点魔力({}→{})".format(player_data["昵称"], mp_01, mp_02)
                            elif random1 > 50 and random1 <= 75:
                                debuffs = [d for d in player_status if d['类型'] == '控制']
                                if debuffs:
                                    removed_item = random.choice(debuffs)
                                    player_status.remove(removed_item)
                                    txt += "\n♥小史莱姆♥净化了[{}]的状态".format(player_data["昵称"])
                                else:
                                    debuffs = [d for d in player_status if d['类型'] == '减益']
                                    if debuffs:
                                        removed_item = random.choice(debuffs)
                                        player_status.remove(removed_item)
                                        txt += "\n♥小史莱姆♥吞噬了[{}]的一条减益".format(player_data["昵称"])
                                    else:
                                        hp_01 = player_data["生命"]["当前"]
                                        player_data["生命"]["当前"] += 66
                                        if player_data["生命"]["当前"] > player_data["生命"]["当前最大"]:
                                            player_data["生命"]["当前"] = player_data["生命"]["当前最大"]
                                        hp_02 = player_data["生命"]["当前"]
                                        txt += "\n♥小史莱姆♥为[{}]恢复了66点生命({}→{})".format(player_data["昵称"], hp_01, hp_02)
                            else:
                                txt += "\n♥小史莱姆♥正在努力跟上战斗节奏。。。"
                            continue


                    elif status1["类型"] == "获得":
                        if status1["属性"] == "生命回复":
                            hp_01 = player_data["生命"]["当前"]
                            hp_up = int(player_data["生命"]["当前最大"] * status1["数值"] / 100)
                            hp_level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "不灭意志"] or [0]
                            if hp_level[0] > 0:
                                hp_up = hp_up * (1 + 0.2 * hp_level[0] * (player_data["生命"]["当前最大"] - player_data["生命"]["当前"]) / player_data["生命"]["当前最大"])
                            hp_up = int(hp_up)

                            player_data["生命"]["当前"] += hp_up
                            if player_data["生命"]["当前"] > player_data["生命"]["当前最大"]:
                                player_data["生命"]["当前"] = player_data["生命"]["当前最大"]
                            hp_02 = player_data["生命"]["当前"]
                            txt += "\n#{}#[{}]生命({}→{})".format(status1["名称"], player_data["昵称"], hp_01, hp_02)
                        elif status1["属性"] == "已损失生命回复":
                            hp_01 = player_data["生命"]["当前"]
                            hp_up = int((player_data["生命"]["当前最大"] - player_data["生命"]["当前"]) * status1["数值"] / 100)
                            hp_level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "不灭意志"] or [0]
                            if hp_level[0] > 0:
                                hp_up = hp_up * (1 + 0.2 * hp_level[0] * (player_data["生命"]["当前最大"] - player_data["生命"]["当前"]) / player_data["生命"]["当前最大"])
                            hp_up = int(hp_up)

                            player_data["生命"]["当前"] += hp_up
                            if player_data["生命"]["当前"] > player_data["生命"]["当前最大"]:
                                player_data["生命"]["当前"] = player_data["生命"]["当前最大"]
                            hp_02 = player_data["生命"]["当前"]
                            txt += "\n#{}#[{}]生命({}→{})".format(status1["名称"], player_data["昵称"], hp_01, hp_02)

                            
                            
                    elif status1["类型"] == "流失":
                        if_found = False
                        for run_blood in run_blood_effect:
                            if status1["名称"] == run_blood["名称"] and status1["属性"] == run_blood["属性"]:
                                if_found = True
                                run_blood["数值"] += status1["数值"]
                                break
                        if not if_found:
                            run_blood_effect.append({"名称": status1["名称"], "属性": status1["属性"], "数值": status1["数值"]})
                        continue
                    elif status1["类型"] == "控制":
                        if status1["属性"] == "眩晕":
                            can_attack = False
                            use_prop = False
                            do_hit = False
                            buff_skill = False
                            combo_hit = False
                            if_combo_hit = False
                            if_hit = False
                            txt += "\n【[{}]眩晕中。。。】".format(player_data["昵称"])
                        continue
                

                for run_blood in run_blood_effect:
                    if run_blood["属性"] == "最大生命百分比":
                        hp_01 = player_data["生命"]["当前"]
                        player_data["生命"]["当前"] -= math.floor(player_data["生命"]["当前最大"] * run_blood["数值"] / 100)
                        if player_data["生命"]["当前"] < 0:
                            player_data["生命"]["当前"] = 0
                        hp_02 = player_data["生命"]["当前"]
                        txt += "\n${}$[{}]流失生命值({}→{})".format(run_blood["名称"], player_data["昵称"], hp_01, hp_02)
                    elif run_blood["属性"] == "当前生命百分比":
                        hp_01 = player_data["生命"]["当前"]
                        player_data["生命"]["当前"] -= math.floor(player_data["生命"]["当前"] * run_blood["数值"] / 100)
                        if player_data["生命"]["当前"] < 0:
                            player_data["生命"]["当前"] = 0
                        hp_02 = player_data["生命"]["当前"]
                        txt += "\n${}$[{}]流失生命值({}→{})".format(run_blood["名称"], player_data["昵称"], hp_01, hp_02)
                    elif run_blood["属性"] == "固定生命值":
                        hp_01 = player_data["生命"]["当前"]
                        player_data["生命"]["当前"] -= math.floor(run_blood["数值"])
                        if player_data["生命"]["当前"] < 0:
                            player_data["生命"]["当前"] = 0
                        hp_02 = player_data["生命"]["当前"]
                        txt += "\n${}$[{}]流失生命值({}→{})".format(run_blood["名称"], player_data["昵称"], hp_01, hp_02)

                if player_data["生命"]["当前"] <= 0:
                    txt += "\n【[{}]已丧失战斗能力】".format(player_data["昵称"])
                    survivor_final = [sur for sur in data["玩家"] if sur["生命"]["当前"] > 0]
                    monster_final = [sur for sur in data["敌人"] if sur["生命"]["当前"] > 0]
                    if survivor_final == [] or monster_final == []:
                        break
                    else:
                        continue
                if_mp_0 = False
                if_ad_attack = False
                if_ap_attack = False
                if_skill = False
                if any(player_equ_effect["名称"] == "破法Ⅰ" for player_equ_effect in player_data["效果"]):
                    data["敌人"][0]["魔防"]["当前"] *= 0.9
                if "使用" in player_data["出招"] and can_attack == True:
                    use_prop = True
                    do_hit = False
                    buff_skill = False
                    if_hit = False
                    if_combo_hit = False
                    combo_hit = False
                    use_thing = player_data["出招"].split("使用")[1]
                    txt += "\n【{}使用了[{}]】".format(player_data["昵称"], use_thing)
                    max_hp = player_data["生命"]["当前最大"]
                    now_hp = player_data["生命"]["当前"]
                    max_mp = player_data["魔力"]["当前最大"]
                    now_mp = player_data["魔力"]["当前"]
                    if_hp = False
                    if_mp = False
                    if use_thing == "草莓":
                        if_hp = True
                        up_hp = 888
                    if use_thing == "小血瓶":
                        if_hp = True
                        up_hp = max_hp * 0.01 + 100
                    if use_thing == "中血瓶":
                        if_hp = True
                        up_hp = max_hp * 0.02 + 300
                    if use_thing == "大血瓶":
                        if_hp = True
                        up_hp = max_hp * 0.03 + 1000
                    if use_thing == "蓝莓":
                        if_mp = True
                        up_mp = 888
                    if use_thing == "小魔瓶":
                        if_mp = True
                        up_mp = max_mp * 0.01 + 100
                    if use_thing == "中魔瓶":
                        if_mp = True
                        up_mp = max_mp * 0.02 + 300
                    if use_thing == "大魔瓶":
                        if_mp = True
                        up_mp = max_mp * 0.03 + 1000
                    if use_thing == "闪亮的祝福":
                        if_mp = True
                        up_mp = max_mp * 0.5
                        if_hp = True
                        up_hp = max_hp * 0.5
                    if if_hp:
                        up_hp = int(up_hp)
                        hp_level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "不灭意志"] or [0]
                        if hp_level[0] > 0:
                            up_hp = up_hp * (1 + 0.2 * hp_level[0] * (player_data["生命"]["当前最大"] - player_data["生命"]["当前"]) / player_data["生命"]["当前最大"])
                        up_hp = int(up_hp)
                        hp_now = now_hp + up_hp
                        if hp_now > max_hp:
                            hp_now = max_hp
                        player_data["生命"]["当前"] = hp_now
                        txt += "\n◈生命回复了{}({}→{})".format(up_hp, now_hp, hp_now)
                    if if_mp:
                        up_mp = int(up_mp)
                        mp_now = now_mp + up_mp
                        if mp_now > max_mp:
                            mp_now = max_mp
                        player_data["魔力"]["当前"] = mp_now
                        txt += "\n◈魔力回复了{}({}→{})".format(up_mp, now_mp, mp_now)
                    if use_thing == "天罚符咒":
                        enemy_hp1 = data["敌人"][0]["生命"]["当前"]
                        if random.random() < 0.6:
                            enemy_harm = enemy_hp1 * 0.3 + 333
                            if enemy_harm > 5000:
                                enemy_harm = 5000
                            txt += "\n◈一道闪电自空中劈下，径直落在[{}]身上。".format(data["敌人"][0]["昵称"])
                        elif random.random() < 0.9:
                            enemy_harm = enemy_hp1 * 0.6 + 666
                            if enemy_harm > 10000:
                                enemy_harm = 10000
                            txt += "\n◈天空一声巨响，粗壮的落雷轰击在[{}]上。".format(data["敌人"][0]["昵称"])
                        elif random.random() < 0.99:
                            if enemy_harm > 20000:
                                enemy_harm = 20000
                            enemy_harm = enemy_hp1 * 0.9 + 999
                            txt += "\n◈九霄之上，一道紫雷凌空而下，蕴含着恐怖的能量。[{}]被击中，顷刻间碎石飞扬，烟雾弥漫。".format(data["敌人"][0]["昵称"])
                        else:
                            enemy_harm = enemy_hp1 * 0.9 + 999999
                            txt += "\n◈霎时间风云变色，天空被黑暗笼罩。隐约可见那一抹黑幕后，竟藏有五颜六色的光彩。少时这些姹紫嫣红冲破了云层，向地面压来，承载着汹涌而又恐怖的能量。沉重的压迫下，[{}]动弹不得，被七彩雷霆所淹没，再难起身。".format(data["敌人"][0]["昵称"])
                        enemy_harm = int(enemy_harm)
                        enemy_hp2 = int(enemy_hp1 - enemy_harm)
                        if enemy_hp2 < 0:
                            enemy_hp2 = 0
                        data["敌人"][0]["生命"]["当前"] = int(enemy_hp2)
                        txt += "({}→{})".format(enemy_hp1, enemy_hp2)


                    await bag_reduce(player_data["uid"], use_thing, 1)

                """等级压制"""
                """等级压制"""
                """等级压制"""
                difference = player_data["等级"] - data["敌人"][0]["等级"]
                if difference <= 2 and difference >= -2:
                    press = 0
                    harm_press = 1
                elif difference > 2:
                    press = difference - 2
                    harm_press = 1.1 ** press
                elif difference < -2:
                    press = -(difference + 2)
                    harm_press = 0.9 ** press
                    txt += "\n⚠︎你感受到无形的威压⚠︎"
                """等级压制"""
                """等级压制"""
                """等级压制"""

                
                if "普攻" in player_data["出招"] and can_attack == True:
                    attack_0 = "无"
                    if_ad_attack = True
                    if_ap_attack = False
                    use_prop = False
                    combo_hit = True
                    buff_skill = False
                    if_skill = False
                    if_a = True
                    skill0_effect = []
                    txt += "\n【{}普通攻击】".format(player_data["昵称"])

                elif "技能" in player_data["出招"] and can_attack == True:

                    if_skill = True
                    if_a = False
                    use_prop = False

                    if_combine_skill = False
                    if_combine_skill_max = False

                    if "·组合技" in player_data["出招"]:
                        if_combine_skill = True
                        player_data["出招"] = player_data["出招"].split("·组合技")[0]
                    elif "·强化组合技" in player_data["出招"]:
                        if_combine_skill_max = True
                        player_data["出招"] = player_data["出招"].split("·强化组合技")[0]
                    
                    if if_combine_skill or if_combine_skill_max:
                        if not any(in_player_data.get("主人uid", "") == player_data["uid"] for in_player_data in data["玩家"]):
                            if_combine_skill = False
                            if_combine_skill_max = False

                    skill0_number = int(player_data["出招"].split("技能")[1])
                    skill0_name = player_data["技能"][skill0_number - 1]["名称"]
                    skill0_level = player_data["技能"][skill0_number - 1]["等级"]
                    with open(f"data/skills/{skill0_name}.txt", 'r') as f:
                        skill0_data = json.load(f)

                    skill0_effect = skill0_data["效果"]
                    if skill0_data.get("冷却", 0) > 0:
                        player_data["技能"][skill0_number - 1]["冷却"] = int(skill0_data["冷却"] + 1)
                    if_skill_change_power = False
                    if_skill_change_harm_up = False
                    if_skill_change_effect = False
                    if_skill_change_value = 0

                    if if_combine_skill or if_combine_skill_max:
                        if_change_skill = False
                        for in_skill0_effect in skill0_effect:
                            if if_combine_skill and in_skill0_effect["类型"] == "变招" and in_skill0_effect["属性"] == "组合技":
                                if_change_skill = True
                                skill0_name = in_skill0_effect["数值"]
                                break
                            if if_combine_skill_max and in_skill0_effect["类型"] == "变招" and in_skill0_effect["属性"] == "强化组合技":
                                if_change_skill = True
                                skill0_name = in_skill0_effect["数值"]
                                break

                        if if_change_skill:
                            with open(f"data/skills/{skill0_name}.txt", 'r') as f:
                                skill0_data = json.load(f)
                        else:
                            if_skill_change_random = random.random()
                            if if_skill_change_random < 0.4:
                                if_skill_change_harm_up = True
                                if if_combine_skill:
                                    if_skill_change_value = random.randint(50, 100)
                                    skill0_name += "·双"
                                elif if_combine_skill_max:
                                    if_skill_change_value = random.randint(80, 250)
                                    skill0_name += "·无双"
                            elif if_skill_change_random < 0.8:
                                if_skill_change_power = True
                                if if_combine_skill:
                                    if_skill_change_value = random.randint(25, 50)
                                    skill0_name += "·极"
                                elif if_combine_skill_max:
                                    if_skill_change_value = random.randint(40, 100)
                                    skill0_name += "·无极"
                            else:
                                if_skill_change_effect = True
                                if if_combine_skill:
                                    if_skill_change_value = random.randint(25, 50)
                                    skill0_name += "·乱"
                                elif if_combine_skill_max:
                                    if_skill_change_value = random.randint(40, 100)
                                    skill0_name += "·狂乱"

                    skill0_power = int(skill0_data["威力"])

                    if if_skill_change_power:
                        skill0_power *= (100 + if_skill_change_value) / 100

                    skill0_class = skill0_data["类别"]
                    skill0_shuxing = skill0_data["属性"]
                    attack_0 = skill0_shuxing
                    skill0_effect = skill0_data["效果"]
                    skill0_mp = int(skill0_data["蓝耗"])
                    level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "医者仁心"] or [0]
                    if level[0] > 0:
                        skill0_mp = skill0_mp * (1 - 0.08 * level[0])

                    if if_combine_skill:
                        txt += "\n【{}协同分身施放技能[{}]】".format(player_data["昵称"], skill0_name)
                    elif if_combine_skill_max:
                        txt += "\n【{}同调分身施放技能[{}]】".format(player_data["昵称"], skill0_name)
                    else:
                        txt += "\n【{}施放技能[{}]】".format(player_data["昵称"], skill0_name)

                    if if_skill_change_power:
                        if if_combine_skill:
                            txt += "\n#极#威力提升{}%".format(if_skill_change_value)
                        if if_combine_skill_max:
                            txt += "\n#无极#威力提升{}%".format(if_skill_change_value)
                    if if_skill_change_harm_up:
                        if if_combine_skill:
                            txt += "\n#双#伤害增加{}%".format(if_skill_change_value)
                        if if_combine_skill_max:
                            txt += "\n#无双#伤害增加{}%".format(if_skill_change_value)
                    if if_skill_change_effect:
                        if if_combine_skill:
                            txt += "\n#乱#效果加强{}%".format(if_skill_change_value)
                        if if_combine_skill_max:
                            txt += "\n#狂乱#效果加强{}%".format(if_skill_change_value)

                    combo_hit = False
                    if skill0_class == "物理":
                        combo_hit = True
                        if_ad_attack = True
                        if_ap_attack = False
                        buff_skill = False
                    elif skill0_class == "魔法":
                        combo_hit = True
                        if_ad_attack = False
                        if_ap_attack = True
                        buff_skill = False
                    elif skill0_class == "属性":
                        combo_hit = False
                        if_ad_attack = False
                        if_ap_attack = False
                        buff_skill = True
                    else:
                        combo_hit = False
                        if_ad_attack = False
                        if_ap_attack = False
                        buff_skill = False

                
                if_邪视 = False
                if can_attack and not buff_skill:
                    if if_player_unlimit_combo:
                        player_many_hit = 99
                        combo_hit = False
                        txt += "\n#{}#无限连击！".format(player_unlimit_combo_name)

                    if any(player_equ_effect["名称"] == "邪视" for player_equ_effect in player_data["效果"]):
                        if_邪视 = True
                        attack_0 = "暗"
                        txt += "\n👁︎#邪视#造成暗魔法伤害"
                
                """命 闪 暴 连击效果计算"""
                """命 闪 暴 连击效果计算"""
                """命 闪 暴 连击效果计算"""
                if_must_hit = False
                if_must_crit = False
                if if_skill and if_mp_0 == False and buff_skill == False and use_prop == False and can_attack == True:
                    for effect in skill0_effect:
                        if effect["目标"] == "自身":
                            if effect["类型"] == "必定":
                                if effect["属性"] == "命中":
                                    if_must_hit = True
                                    txt += "\n#{}#必定命中！".format(effect["名称"])
                                elif effect["属性"] == "暴击":
                                    if_must_crit = True
                                    txt += "\n#{}#必定暴击！".format(effect["名称"])
                            if effect["类型"] == "连击" and if_player_unlimit_combo == False:
                                if effect["属性"] == "相同":
                                    player_many_hit = effect["数值"]
                                    txt += "\n#{}#疾速{}连击！".format(effect["名称"], effect["数值"])
                                if effect["属性"] == "散射":
                                    player_many_hit = effect["数值"]
                                    txt += "\n#{}#{}连散射！".format(effect["名称"], effect["数值"])
                        
                            if effect["类型"] == "提升":
                                if effect["属性"] in ["命中", "暴击", "暴伤", "速度"]:
                                    player_data[effect["属性"]]["当前"] *= (100 + effect["数值"]) / 100
                                elif effect["属性"] == "物理穿透":
                                    player_data["物理穿透"]["当前"] = round(float((1 - (100 - player_data["物理穿透"]["当前"]) * (100 - float(effect["数值"])) / 10000) * 100), 2)
                                txt += "\n#{}#{}提升{}%！".format(effect["名称"], effect["属性"], effect["数值"])



                """命 闪 暴 连击效果计算"""
                """命 闪 暴 连击效果计算"""
                """命 闪 暴 连击效果计算"""
                if player_many_hit > 1:
                    combo_hit = False

                for player_x_hit in range(player_many_hit):

                    if buff_skill or can_attack == False:
                        break

                    
                    """计算实际 连 追 命 暴"""
                    """计算实际 连 追 命 暴"""
                    """计算实际 连 追 命 暴"""
                    if buff_skill == False and use_prop == False and can_attack == True:
                        
                        
                        combo_percent = 1 - 0.5 ** ((player_data["速度"]["当前"] * harm_press - data["敌人"][0]["速度"]["当前"]) / data["敌人"][0]["速度"]["当前"])

                        hit_percent = 1 - 0.5 ** (player_data["命中"]["当前"] * harm_press / (data["敌人"][0]["闪避"]["当前"]))

                        if hit_percent < player_data["最低命中率"]["当前"] * 0.01:
                           hit_percent = player_data["最低命中率"]["当前"] * 0.01

                        if if_player_unlimit_combo:
                            player_data["命中"]["当前"] *= 0.5
                    
                        crit_percent = 1 - 0.5 ** (player_data["暴击"]["当前"] * harm_press / data["敌人"][0]["暴免"]["当前"])
                    
                        x = player_data["暴伤"]["当前"] * harm_press / data["敌人"][0]["暴抗"]["当前"]
                        if x < 1:
                            crit_harm = 1 + x
                        else:
                            crit_harm = 2 + math.log(x, 3)

                        level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "元素爆发"] or [0]
                        if crit_harm > 3:
                            if level[0] == 0:
                                crit_harm = 3
                            else:
                                crit_harm_max = 3 + level[0] * 0.3
                                crit_harm = min(crit_harm, crit_harm_max)
                    
                        combo_max = math.ceil(([skill["等级"] for skill in player_data["效果"] if skill["名称"] == "弱点洞察"] or [0])[0] / 3) + 1
                        combo_number = 0
                        for i in range(combo_max):
                            if random.random() < combo_percent and combo_hit == True:
                                combo_number += 1
                            else:
                                break
    
                        if random.random() <= hit_percent:
                            if_hit = True
                        else:
                            if_hit = False
            
                        if random.random() <= crit_percent:
                            if_crit = True
                        else:
                            if_crit = False

                        if if_must_hit:
                            if_hit = True
                        if if_must_crit:
                            if_crit = True

                    """计算实际 连 追 命 暴"""
                    """计算实际 连 追 命 暴"""
                    """计算实际 连 追 命 暴"""

                    harm = 0
                    if if_hit and use_prop == False and can_attack == True and buff_skill == False:
                        """穿透计算"""
                        """穿透计算"""
                        """穿透计算"""
                        true_defend = data["敌人"][0]["物防"]["当前"] * (100 - player_data["物理穿透"]["当前"]) / 100
                        true_magic_defend = data["敌人"][0]["魔防"]["当前"] * (100 - player_data["魔法穿透"]["当前"]) / 100
                        """穿透计算"""
                        """穿透计算"""
                        """穿透计算"""
                        if if_a and can_attack:
                            if not if_邪视:
    
                                harm = player_data["物攻"]["当前"] * player_data["物攻"]["当前"] / (player_data["物攻"]["当前"] + true_defend)
                                harm *= ((100 + player_data["物理增伤"]["当前"]) / 100)
                                harm *= ((100 - data["敌人"][0]["物理减伤"]["当前"]) / 100)

                            else:

                                harm = player_data["物攻"]["当前"] * player_data["物攻"]["当前"] / (player_data["物攻"]["当前"] + true_magic_defend)
                                harm *= ((100 + player_data["魔法增伤"]["当前"]) / 100)
                                harm *= ((100 - data["敌人"][0]["魔法减伤"]["当前"]) / 100)

    
                        elif if_skill and can_attack:
                            if if_ad_attack:
                                if if_邪视:
                                    harm = player_data["物攻"]["当前"] * (skill0_power / 100) * player_data["物攻"]["当前"] * (skill0_power / 100)/ (player_data["物攻"]["当前"] * (skill0_power / 100) + true_magic_defend)

                                else:
                                    harm = player_data["物攻"]["当前"] * (skill0_power / 100) * player_data["物攻"]["当前"] * (skill0_power / 100)/ (player_data["物攻"]["当前"] * (skill0_power / 100) + true_defend)

                                use_mp = skill0_mp
                                if player_data["魔力"]["当前"] >= use_mp:
                                    player_data["魔力"]["当前"] -= use_mp

                                else:
                                    player_data["魔力"]["当前"] = 0
                                    if player_data["魔力"]["当前"] / use_mp >= 0.1:
                                        harm *= player_data["魔力"]["当前"] / use_mp
                                    else:
                                        harm *= 0.1
                                    txt += "\n╬魔力亏损╬"
                                    if_mp_0 = True
                            elif if_ap_attack:

                                if any(player_equ_effect["名称"] == "暗附魔" for player_equ_effect in player_data["效果"]):
                                    attack_0 = "暗"
                                    harm = player_data["魔攻"]["当前"] * (skill0_power / 100) * player_data["魔攻"]["当前"] * (skill0_power / 100)/ (player_data["魔攻"]["当前"] * (skill0_power / 100) + true_magic_defend)

                                else:
                                    harm = player_data["魔攻"]["当前"] * (skill0_power / 100) * player_data["魔攻"]["当前"] * (skill0_power / 100)/ (player_data["魔攻"]["当前"] * (skill0_power / 100) + true_magic_defend)


                                use_mp = skill0_mp
                                if player_data["魔力"]["当前"] >= use_mp:
                                    player_data["魔力"]["当前"] -= use_mp

                                else:
                                    player_data["魔力"]["当前"] = 0
                                    if player_data["魔力"]["当前"] / use_mp >= 0.1:
                                        harm *= player_data["魔力"]["当前"] / use_mp
                                    else:
                                        harm *= 0.1
                                    txt += "\n╬魔力亏损╬"
                                    if_mp_0 = True

                            elif buff_skill:

                                use_mp = math.ceil(skill0_mp)

                                if player_data["魔力"]["当前"] >= use_mp:
                                    player_data["魔力"]["当前"] -= use_mp
                                elif player_data["魔力"]["当前"] == 0:
                                    txt += "\n╬魔力亏损╬"
                                    if_mp_0 = True
                                else:
                                    player_data["魔力"]["当前"] = 0
                                if_hit = False
                                if_combo_hit = False
                        

                        if (if_ad_attack or if_ap_attack) and if_skill:
                            for effect in skill0_effect:
                                if effect["目标"] == "自身" and if_mp_0 == False:
                                    if effect["类型"] == "伤害":
                                        txt += "\n#{}#".format(effect["名称"])
                                        attribute = effect["属性"]
                                        if attribute == "增幅":
                                            harm_up = harm * effect["数值"] / 100
                                            harm += harm_up
                                            if effect["数值"] <=20:
                                                word = "小幅"
                                            elif effect["数值"] > 20 and effect["数值"] <= 40:
                                                word = "中幅"
                                            elif effect["数值"] > 40 and effect["数值"] <= 60:
                                                word = "大幅"
                                            elif effect["数值"] > 60 and effect["数值"] <= 80:
                                                word = "巨大幅"
                                            elif effect["数值"] > 80 and effect["数值"] <= 100:
                                                word = "极大幅"
                                            elif effect["数值"] > 100:
                                                word = "超幅"
                                            txt += "基础伤害{}提升({})".format(word, math.floor(harm_up))

                                        elif attribute == "附加攻击百分比":
                                            harm_up = (player_data["物攻"]["当前"] + player_data["魔攻"]["当前"]) * effect["数值"] / 100
                                            harm += harm_up
                                            if effect["数值"] <=20:
                                                word = "小幅"
                                            elif effect["数值"] > 20 and effect["数值"] <= 40:
                                                word = "中幅"
                                            elif effect["数值"] > 40 and effect["数值"] <= 60:
                                                word = "大幅"
                                            elif effect["数值"] > 60 and effect["数值"] <= 80:
                                                word = "巨大幅"
                                            elif effect["数值"] > 80 and effect["数值"] <= 100:
                                                word = "极大幅"
                                            elif effect["数值"] > 100:
                                                word = "超幅"
                                            txt += "附加{}面板伤害({})".format(word, math.floor(harm_up))

                                        elif attribute == "血肉拥抱":
                                            harm_up = 0
                                            for in_effect in player_data["效果"]:
                                                if in_effect["名称"] == "古神血脉" and in_effect["类型"] == "流失":
                                                    harm_up += int(in_effect["数值"] * in_effect["回合"])
                                            player_data["效果"] = [in_effect for in_effect in player_data["效果"] if not (in_effect["名称"] == "古神血脉" and in_effect["类型"] == "流失")]
                                            harm_up = math.ceil(harm_up * effect["数值"] / 100)
                                            harm += harm_up
                                            txt += "基础伤害提升{}".format(harm_up)

                                        elif attribute == "魔力乱流":
                                            harm_up = math.ceil(player_data["魔力"]["当前"] * effect["数值"] / 100)
                                            player_data["魔力"]["当前"] = math.ceil(player_data["魔力"]["当前"] * (100 - effect["数值"]) / 100)
                                            harm += harm_up
                                            txt += "基础伤害提升{}".format(harm_up)

                                elif effect["类型"] == "装备":
                                
                                    if effect["名称"] == "光附魔":
                                        attack_0 = "光"
                                        harm_up = int(harm * 0.1)
                                        harm += harm_up
                                        txt += "\n✡#光附魔#伤害转变为光属性\n光伤害提升10%({})".format(harm_up)

                                    if effect["名称"] == "暗附魔":
                                        attack_0 = "暗"
                                        harm_up = int(harm * 0.1)
                                        harm += harm_up
                                        txt += "\n✡#暗附魔#伤害转变为暗属性\n暗伤害提升10%({})".format(harm_up)

                                    elif effect["名称"] == "伤害加深Ⅰ":
                                        harm_up = int(harm * 0.1)
                                        harm += harm_up
                                        txt += "\n#伤害加深Ⅰ#伤害提升10%({})".format(harm_up)


                        if any(job_effect["名称"] == "魔导极致" for job_effect in player_data["效果"]) and if_ap_attack and if_skill:
                            harm_up_percent = player_data["魔力"]["当前"] / player_data["魔力"]["当前最大"]
                            harm += math.ceil(harm_up_percent * harm)
                            txt += "\n#魔导极致#伤害提升{}%".format(math.ceil(harm_up_percent * 100))

                        if if_skill:
                            if if_skill_change_harm_up:
                                harm += math.ceil(harm * if_skill_change_value / 100)


                        if if_a and can_attack:
                            if if_邪视:
                                harm *= ((100 + player_data["魔法增伤"]["当前"]) / 100)
                                harm *= ((100 - data["敌人"][0]["魔法减伤"]["当前"]) / 100)
                            else:
                                harm *= ((100 + player_data["物理增伤"]["当前"]) / 100)
                                harm *= ((100 - data["敌人"][0]["物理减伤"]["当前"]) / 100)
                        if if_skill and can_attack:
                            if if_ad_attack:
                                if if_邪视:
                                    harm *= ((100 + player_data["魔法增伤"]["当前"]) / 100)
                                    harm *= ((100 - data["敌人"][0]["魔法减伤"]["当前"]) / 100)
                                else:
                                    harm *= ((100 + player_data["物理增伤"]["当前"]) / 100)
                                    harm *= ((100 - data["敌人"][0]["物理减伤"]["当前"]) / 100)
                            elif if_ap_attack:
                                harm *= ((100 + player_data["魔法增伤"]["当前"]) / 100)
                                harm *= ((100 - data["敌人"][0]["魔法减伤"]["当前"]) / 100)
                        

                        if harm_press <= 1:
                            harm *= harm_press
                        harm_combo = harm

                        harm *= random.uniform(0.9, 1.1)
                        
                        txt += "\n◈"
                        if if_player_unlimit_combo:
                            txt += "✦{}连✦".format(player_x_hit + 1)

                        if if_crit:
                            harm *= crit_harm
                            txt += "[暴击!]"

                            if if_ap_attack:
                                level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "元素爆发"] or [0]
                                if level[0] > 0:
                                    harm = harm * (1 + 0.1 * level[0]) 
                                    txt += "⚡"
                        else:
                            txt += ""
                        
                        level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "弱点洞察"] or [0]
                        if level[0] > 0:
                            weak_percent = player_data["速度"]["当前"] / (player_data["速度"]["当前"] + data["敌人"][0]["速度"]["当前"])
                            if random.random() <= weak_percent:
                                harm = harm * (1 + 0.1 * level[0])
                                txt += "💥"


                        skill_fangfan = False
                        if any(passive_effect["类型"] == "防反" for passive_effect in data["敌人"][0]["效果"]):
                            skill_fangfan = True
                            for passive_effect in data["敌人"][0]["效果"]:
                                if passive_effect["类型"] == "防反":
                                    skill_atk = (data["敌人"][0]["物防"]["当前"] + data["敌人"][0]["魔防"]["当前"]) / 2 * passive_effect["数值"] / 100
                                    skill_harm = int((skill_atk * skill_atk / (skill_atk + player_data["物防"]["当前"]) + harm / 4) / harm_press * random.uniform(0.9, 1.1))
                                    skill_harm *= (100 - player_data["物理减伤"]["当前"]) / 100
                                    skill_harm = math.ceil(skill_harm)
                                    harm = harm * 3 / 4
                                    if harm <=1:
                                        harm = 1
                                    player_hp11 = player_data["生命"]["当前"]
                                    player_data["生命"]["当前"] = player_data["生命"]["当前"] - skill_harm
                                    if player_data["生命"]["当前"] < 0:
                                        player_data["生命"]["当前"] = 0
                                    player_hp12 = player_data["生命"]["当前"]
                                    break
                        
                        skill_anti = False
                        if any(passive_effect["类型"] == "反震" for passive_effect in data["敌人"][0]["效果"]) and if_ad_attack == True:
                            skill_anti = True
                            for passive_effect in data["敌人"][0]["效果"]:
                                if passive_effect["类型"] == "反震":
                                    if if_a:
                                        skill0_power = 100
                                    anti_harm = (player_data["物攻"]["当前"] * (skill0_power / 100) * player_data["物攻"]["当前"] * (skill0_power / 100)/ (player_data["物攻"]["当前"] * (skill0_power / 100) + player_data["物防"]["当前"])) * passive_effect["数值"] / 100
                                    anti_harm *= (100 - player_data["物理减伤"]["当前"]) / 100
                                    anti_harm = math.ceil(anti_harm / harm_press * random.uniform(0.9, 1.1))
                                    if anti_harm < 1:
                                        anti_harm = 1
                                    player_hp21 = player_data["生命"]["当前"]
                                    player_data["生命"]["当前"] = player_data["生命"]["当前"] - anti_harm
                                    if player_data["生命"]["当前"] < 0:
                                        player_data["生命"]["当前"] = 0
                                    player_hp22 = player_data["生命"]["当前"]
                                    break
                        

                        harm = math.floor(harm)
                            

                        if harm <=1:
                            harm = 1
                        player_data["仇恨"] += harm
                        player_data["累计伤害"] += harm
                        txt += "对 {} 造成了{}点伤害".format(data["敌人"][0]["昵称"], harm)
                        hp_1 = int(data["敌人"][0]["生命"]["当前"])
                        data["敌人"][0]["生命"]["当前"] -= harm
                        hp_2 = int(data["敌人"][0]["生命"]["当前"])
                        if hp_2 < 0:
                            hp_2 = 0
                        data["敌人"][0]["生命"]["当前"] = hp_2
                        txt += "({}→{})".format(hp_1, hp_2)

                        if skill_fangfan:
                            txt += "\n🛡$防反$受到{}点伤害({}→{})".format(skill_harm, player_hp11, player_hp12)
                        if skill_anti:
                            txt += "\n🦔$反震$受到{}点伤害({}→{})".format(anti_harm, player_hp21, player_hp22)

                        for effect in skill0_effect:
                            if if_mp_0 == True:
                                break
                            if effect["目标"] == "对方":
                                if effect["类型"] == "增益":
                                    txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                    attribute = effect["属性"].split("/")
                                    for atbt in attribute:
                                        data["敌人"][0]["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": atbt, "数值": effect["数值"], "回合": effect["回合"]})
                                        data["敌人"][0][atbt]["当前"] *= (100 + effect["数值"]) / 100
                                        txt += "[{}]的{}提升了！".format(data["敌人"][0]["昵称"], atbt)

                                elif effect["类型"] == "减益":
                                    txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                    attribute = effect["属性"].split("/")
                                    effect_value = effect["数值"]
                                    effect_time = effect["回合"]
                                    for atbt in attribute:
                                        if if_skill_change_effect:
                                            effect_value = round(effect["数值"] * (100 + if_skill_change_value) / 100, 2)
                                            effect_time = effect["回合"] + 1
                                        data["敌人"][0]["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": atbt, "数值": effect_value, "回合": effect_time})
                                        data["敌人"][0][atbt]["当前"] *= (100 - effect["数值"]) / 100
                                        txt += "[{}]的{}降低了！".format(data["敌人"][0]["昵称"], atbt)

                                elif effect["类型"] == "流失":
                                    txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                    attribute = effect["属性"].split("/")
                                    for atbt in attribute:
                                        data["敌人"][0]["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": atbt, "数值": effect["数值"], "回合": effect["回合"]})
                                        txt += "[{}]持续流失{}！".format(data["敌人"][0]["昵称"], atbt)

                                elif effect["类型"] == "生命汲取":
                                    txt += "\n#{}#".format(effect["名称"])
                                    if effect["属性"] == "伤害":
                                        if effect["数值"] == "已损失生命百分比":
                                            absorb_percent = round((player_data["生命"]["当前最大"] - player_data["生命"]["当前"]) / player_data["生命"]["当前最大"] , 2)
                                        else:
                                            absorb_percent = int(effect["数值"]) / 100
                                    absorb_number = math.ceil(harm * absorb_percent)
                                    skill_absorb_before = player_data["生命"]["当前"]
                                    skill_absorb_after = skill_absorb_before + absorb_number
                                    if skill_absorb_after > player_data["生命"]["当前最大"]:
                                        skill_absorb_after = player_data["生命"]["当前最大"]
                                    player_data["生命"]["当前"] = skill_absorb_after
                                    txt += "生命汲取{}({}→{})！".format(absorb_number, skill_absorb_before, skill_absorb_after)

                            elif effect["目标"] == "自身":
                                if effect["类型"] == "命中增益":
                                    txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                    attribute = effect["属性"].split("/")
                                    buff_value = effect["数值"]
                                    buff_time = effect["回合"]
                                    if if_skill_change_effect:
                                        buff_time = effect["回合"] + 1
                                        buff_value = math.floor(effect["数值"] * (100 + if_skill_change_value) / 100)
                                    for atbt in attribute:
                                        player_data["效果"].append({"名称": effect["名称"], "类型": "增益", "属性": atbt, "数值": buff_value, "回合": buff_time})
                                        player_data[atbt]["当前"] *= (100 + buff_value) / 100
                                        txt += "\n[{}]的{}提升了！".format(player_data["昵称"], atbt)


                        if if_ad_attack:
                            level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "生命吸收"] or [0]
                            if level[0] > 0:
                                hp_absorb = int(0.06 * harm * level[0])
                                hp_now = int(player_data["生命"]["当前"])
                                hp_now0 = hp_now
                                hp_max = int(player_data["生命"]["当前最大"])
                                hp_now += hp_absorb
                                if hp_now > hp_max:
                                    hp_now = hp_max
                                player_data["生命"]["当前"] = int(hp_now)
                                txt += "\n🩸{}({}→{})".format(hp_absorb, hp_now0, player_data["生命"]["当前"])

                        if any(player1["名称"] == "嗜血" for player1 in player_data["效果"]):
                            hp_absorb = int(0.25 * harm)
                            hp_now = int(player_data["生命"]["当前"])
                            hp_now0 = hp_now
                            hp_max = int(player_data["生命"]["当前最大"])
                            hp_now += hp_absorb
                            if hp_now > hp_max:
                                hp_now = hp_max
                            player_data["生命"]["当前"] = int(hp_now)
                            txt += "\n🩸#嗜血#生命汲取{}({}→{})".format(hp_absorb, hp_now0, player_data["生命"]["当前"])

                        if any(player1["名称"] == "撕裂" for player1 in player_data["效果"]):
                            for player1 in player_data["效果"]:
                                for enemy in data["敌人"]:
                                    if not any(enemy1["名称"] == player1["名称"] for enemy1 in enemy["效果"]):
                                        enemy["效果"].append({"名称": player1["名称"], "类型": "被装备", "层数": 1, "回合": 999})
                                    else:
                                        for enemy1 in enemy["效果"]:
                                            if enemy1["名称"] == player1["名称"]:
                                                if "层数" in enemy1:
                                                    enemy1["层数"] = min(enemy1["层数"] + 1, 20)
                                                    break

                        survivor_final = [sur for sur in data["玩家"] if sur["生命"]["当前"] > 0]
                        monster_final = [sur for sur in data["敌人"] if sur["生命"]["当前"] > 0]
                        if monster_final == [] or survivor_final == []:
                            break
                    
                    else:

                        txt += "\n◈[Miss]被 {} 闪避了！".format(data["敌人"][0]["昵称"])
                        combo_hit = False
                        if if_player_unlimit_combo:
                            break


                survivor_final = [sur for sur in data["玩家"] if sur["生命"]["当前"] > 0]
                monster_final = [sur for sur in data["敌人"] if sur["生命"]["当前"] > 0]
                if monster_final == [] or survivor_final == []:
                    break
    
                if combo_hit:
                    harm_combo0 = harm_combo
                    for x in range(combo_number):

                        harm_combo = harm_combo0 * random.uniform(0.9, 1.1)

                        if buff_skill or can_attack == False:
                            break

                        if x == 0:
                            txt += "\n✦追击✦"
                        elif x > 0:
                            txt += "\n✦追击·{}✦".format(x + 1)
                        if random.random() <= hit_percent:
                            if random.random() <= crit_percent:
                                txt += "[暴击!]"
                                harm_combo = harm_combo * crit_harm
                                if if_ap_attack:
                                    level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "元素爆发"] or [0]
                                    if level[0] > 0:
                                        harm_combo = harm_combo * (1 + 0.1 * level[0]) 
                                        txt += "⚡"
                            else:
                                txt += ""

                            level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "弱点洞察"] or [0]
                            if level[0] > 0:
                                weak_percent = player_data["速度"]["当前"] / (player_data["速度"]["当前"] + data["敌人"][0]["速度"]["当前"])
                                if random.random() <= weak_percent:
                                    harm_combo = harm_combo * (1 + 0.06 * level[0])
                                    txt += "💥"

                            skill_fangfan = False
                            if any(passive_effect["类型"] == "防反" for passive_effect in data["敌人"][0]["效果"]):
                                skill_fangfan = True
                                for passive_effect in data["敌人"][0]["效果"]:
                                    if passive_effect["类型"] == "防反":
                                        skill_atk = (data["敌人"][0]["物防"]["当前"] + data["敌人"][0]["魔防"]["当前"]) / 2 * passive_effect["数值"] / 100
                                        skill_harm = int((skill_atk * skill_atk / (skill_atk + player_data["物防"]["当前"]) + harm_combo / 4) / harm_press)
                                        harm_combo = harm_combo * 3 / 4
                                        if harm_combo <= 1:
                                            harm_combo = 1
                                        player_hp11 = player_data["生命"]["当前"]
                                        player_data["生命"]["当前"] = player_data["生命"]["当前"] - skill_harm
                                        if player_data["生命"]["当前"] < 0:
                                            player_data["生命"]["当前"] = 0
                                        player_hp12 = player_data["生命"]["当前"]
                                        break

                        
                            skill_anti = False
                            if any(passive_effect["类型"] == "反震" for passive_effect in data["敌人"][0]["效果"]) and if_ad_attack == True:
                                skill_anti = True
                                for passive_effect in data["敌人"][0]["效果"]:
                                    if passive_effect["类型"] == "反震":
                                        if if_a:
                                            skill0_power = 100
                                        anti_harm = (player_data["物攻"]["当前"] * (skill0_power / 100) * player_data["物攻"]["当前"] * (skill0_power / 100)/ (player_data["物攻"]["当前"] * (skill0_power / 100) + player_data["物防"]["当前"])) * passive_effect["数值"] / 100
                                        anti_harm *= (100 - player_data["物理减伤"]["当前"]) / 100
                                        anti_harm = math.ceil(anti_harm / harm_press * random.uniform(0.9, 1.1))
                                        if anti_harm < 1:
                                            anti_harm = 1
                                        player_hp21 = player_data["生命"]["当前"]
                                        player_data["生命"]["当前"] = player_data["生命"]["当前"] - anti_harm
                                        if player_data["生命"]["当前"] < 0:
                                            player_data["生命"]["当前"] = 0
                                        player_hp22 = player_data["生命"]["当前"]
                                        break

                            harm_combo = math.floor(harm_combo)
                            if harm_combo <=1:
                                harm_combo = 1
                            player_data["仇恨"] += harm_combo
                            player_data["累计伤害"] += harm_combo
                            txt += "对 {} 造成了{}点伤害".format(data["敌人"][0]["昵称"], harm_combo)
                            hp_1 = int(data["敌人"][0]["生命"]["当前"])
                            data["敌人"][0]["生命"]["当前"] -= harm_combo
                            hp_2 = int(data["敌人"][0]["生命"]["当前"])
                            if hp_2 < 0:
                                hp_2 = 0
                            txt += "({}→{})".format(hp_1, hp_2)

                            if skill_fangfan:
                                txt += "\n🛡$防反$受到{}点伤害({}→{})".format(skill_harm, player_hp11, player_hp12)
                            if skill_anti:
                                txt += "\n🦔$反震$受到{}点伤害({}→{})".format(anti_harm, player_hp21, player_hp22)
                    
                            if if_ad_attack and player_data["生命"]["当前"] > 0:
                                level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "生命吸收"] or [0]
                                if level[0] > 0:
                                    hp_absorb = int(0.06 * harm_combo * level[0])
                                    hp_now = int(player_data["生命"]["当前"])
                                    hp_now0 = hp_now
                                    hp_max = int(player_data["生命"]["当前最大"])
                                    hp_now += hp_absorb
                                    if hp_now > hp_max:
                                        hp_now = hp_max
                                    player_data["生命"]["当前"] = int(hp_now)
                                    txt += "\n🩸{}({}→{})".format(hp_absorb, hp_now0, player_data["生命"]["当前"])

                            if any(player1["名称"] == "嗜血" for player1 in player_data["效果"]) and player_data["生命"]["当前"] > 0:
                                hp_absorb = int(0.25 * harm_combo)
                                hp_now = int(player_data["生命"]["当前"])
                                hp_now0 = hp_now
                                hp_max = int(player_data["生命"]["当前最大"])
                                hp_now += hp_absorb
                                if hp_now > hp_max:
                                    hp_now = hp_max
                                player_data["生命"]["当前"] = int(hp_now)
                                txt += "\n🩸#嗜血#生命汲取{}({}→{})".format(hp_absorb, hp_now0, player_data["生命"]["当前"])

                            if any(player1["名称"] == "撕裂" for player1 in player_data["效果"]):
                                for enemy in data["敌人"]:
                                    if not any(enemy1["名称"] == player1["名称"] for enemy1 in enemy["效果"]):
                                        enemy["效果"].append({"名称": player1["名称"], "类型": "被装备", "层数": 1, "回合": 999})
                                    else:
                                        for enemy1 in enemy["效果"]:
                                            if enemy1["名称"] == player1["名称"]:
                                                if "层数" in enemy1:
                                                    enemy1["层数"] = min(enemy1["层数"] + 1, 20)
                                                    break
                                
                            survivor_final = [sur for sur in data["玩家"] if sur["生命"]["当前"] > 0]
                            monster_final = [sur for sur in data["敌人"] if sur["生命"]["当前"] > 0]
                            if monster_final == [] or survivor_final == []:
                                break

                        else:

                            txt += "\n◈[Miss]被 {} 闪避了！".format(data["敌人"][0]["昵称"])
                            break


                survivor_final = [sur for sur in data["玩家"] if sur["生命"]["当前"] > 0]
                monster_final = [sur for sur in data["敌人"] if sur["生命"]["当前"] > 0]
                if monster_final == [] or survivor_final == []:
                    break
                            

                if can_attack == True and use_prop == False:
                    for effect in skill0_effect:
                        if if_mp_0 == True:
                            break
                        if effect["目标"] == "自身": 
                            if effect["类型"] == "回复":
                                txt += "\n#{}#".format(effect["名称"])
                                cure_percent = effect["数值"]
                                cure_value = player_data["魔攻"]["当前"] * cure_percent / 100
                                cure_number = int(cure_value)
                                cure_level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "医者仁心"] or [0]
                                if cure_level[0] > 0:
                                    cure_number = cure_number * (1 + 0.1 * cure_level[0])    
                                hp_01 = player_data["生命"]["当前"]
                                hp_level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "不灭意志"] or [0]
                                if hp_level[0] > 0:
                                    cure_number = cure_number * (1 + 0.2 * hp_level[0] * (player_data["生命"]["当前最大"] - player_data["生命"]["当前"]) / player_data["生命"]["当前最大"])
                                if any(effect["名称"] == "治疗提升Ⅰ" for effect in player_data["效果"]):
                                    cure_number *= 1.2
                                if any(effect["名称"] == "神力加持" for effect in player_data["效果"]):
                                    cure_number *= 1.5
                                cure_number = int(cure_number)
                                player_data["生命"]["当前"] += cure_number
                                if player_data["生命"]["当前"] > player_data["生命"]["当前最大"]:
                                    player_data["生命"]["当前"] = player_data["生命"]["当前最大"]
                                hp_02 = player_data["生命"]["当前"]
                                txt += "[{}]回复生命{}({}→{})".format(player_data["昵称"], cure_number, hp_01, hp_02)

                            elif effect["类型"] == "增益":
                                txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                attribute = effect["属性"].split("/")
                                buff_value = effect["数值"]
                                buff_level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "律者箴言"] or [0]
                                if buff_level[0] > 0:
                                    buff_value = int(buff_value * (1 + 0.1 * buff_level[0]))
                                    txt += "✨"
                                if any(effect["名称"] == "神力加持" for effect in player_data["效果"]):
                                    effect["回合"] = math.ceil(effect["回合"] * 1.3)
                                buff_time = effect["回合"] + 1
                                for atbt in attribute:
                                    player_data["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": atbt, "数值": buff_value, "回合": buff_time})
                                    txt += "[{}]的{}提升了！".format(player_data["昵称"], atbt)

                            elif effect["类型"] == "防反":
                                buff_time = effect["回合"] + 1
                                txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                if not any(eff["类型"] == "防反" for eff in player_data["效果"]):
                                    player_data["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": effect["属性"], "数值": effect["数值"], "回合": buff_time})
                                    txt += "[{}]进入防御反击姿态！".format(player_data["昵称"])
                                else:
                                    for eff in player_data["效果"]:
                                        if eff["类型"] == "防反":
                                            eff["回合"] = effect["回合"]
                                            break
                                    txt += "[{}]持续防御反击姿态！".format(player_data["昵称"])

                            elif effect["类型"] == "获得":
                                buff_time = effect["回合"] + 1
                                txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                attribute = effect["属性"].split("/")
                                for atbt in attribute:
                                    player_data["效果"].append({"名称": effect["名称"], "类型": "获得", "属性": atbt, "数值": effect["数值"], "回合": buff_time})
                                    txt += "[{}]获得{}%{}！".format(player_data["昵称"], effect["数值"], atbt)

                            elif effect["类型"] == "召唤":

                                if effect["属性"] == "影分身":
                
                                    player_call = copy.deepcopy(player_data)
                                    player_call["昵称"] = "{}·影".format(player_data["昵称"])
                                    player_call["uid"] = int("1000000{}".format(player_data["uid"]))
                                    player_call["主人uid"] = player_data["uid"]
                                    player_call["生命"]["最终"] = 1
                                    player_call["生命"]["当前最大"] = 1
                                    player_call["生命"]["当前"] = 1
                                    player_call["效果"] = [player_call_effect for player_call_effect in player_call["效果"] if (player_call_effect["类型"] == "职业" or player_call_effect["类型"] == "被动")]
                                    for player_call_effect in player_call["效果"]:
                                        if "层数" in player_call_effect:
                                            player_call_effect["层数"] = 0

                                    txt += "\n#召唤#[{}]".format(player_call["昵称"])
                                    data["玩家"].append(player_call)
                        
                        else:
                            if effect["类型"] == "召唤强化":
                                if effect["目标"] == "影分身":
                                    for in_player_call in data["玩家"]:
                                        if in_player_call.get("主人uid", "") == player_data["uid"]:
                                            in_player_call["效果"].append({"名称": effect["名称"], "类型": "强化", "属性": "影分身", "数值": 0, "回合": 3})
                                            txt += "\n#强化#(3)与[{}]同调".format(in_player_call["昵称"])
                                            break
                                    


                        if effect["目标"] == "我方群体":
                            if effect["类型"] == "回复":
                                for in_player_data in data["玩家"]:
                                    txt += "\n#{}#".format(effect["名称"])
                                    if in_player_data["生命"]["当前"] <= 0:
                                        txt += "\n[{}]⚰️".format(in_player_data["昵称"])
                                        continue
                                    attribute = effect["属性"].split("/")
                                    for atbt in attribute:
                                        if atbt == "生命值":
                                            cure_percent = effect["数值"]
                                            if cure_percent != "全部":
                                                cure_value = player_data["魔攻"]["当前"] * cure_percent / 100
                                                cure_number = int(cure_value)
                                                cure_level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "医者仁心"] or [0]
                                                if cure_level[0] > 0:
                                                    cure_number = cure_number * (1 + 0.1 * cure_level[0])

                                                hp_01 = in_player_data["生命"]["当前"]
                                                in_hp_level = [skill["等级"] for skill in in_player_data["效果"] if skill["名称"] == "不灭意志"] or [0]
                                                if in_hp_level[0] > 0:
                                                    cure_number = cure_number * (1 + 0.2 * in_hp_level[0] * (in_player_data["生命"]["当前最大"] - in_player_data["生命"]["当前"]) / in_player_data["生命"]["当前最大"])
                                                if any(effect["名称"] == "治疗提升Ⅰ" for effect in player_data["效果"]):
                                                    cure_number *= 1.2
                                                if any(effect["名称"] == "神力加持" for effect in player_data["效果"]):
                                                    cure_number *= 1.5
                                                cure_number = int(cure_number)
                                                in_player_data["生命"]["当前"] += cure_number
                                                if in_player_data["生命"]["当前"] > in_player_data["生命"]["当前最大"]:
                                                    in_player_data["生命"]["当前"] = in_player_data["生命"]["当前最大"]
                                                hp_02 = in_player_data["生命"]["当前"]
                                                txt += "[{}]回复生命{}({}→{})".format(in_player_data["昵称"], cure_number, hp_01, hp_02)
                                            elif cure_percent == "全部":
                                                hp_01 = in_player_data["生命"]["当前"]
                                                in_player_data["生命"]["当前"] = in_player_data["生命"]["当前最大"]
                                                hp_02 = in_player_data["生命"]["当前"]
                                                txt += "[{}]回复全部生命({}→{})".format(in_player_data["昵称"], hp_01, hp_02)
                                        elif atbt == "魔力值":
                                            if cure_percent == "全部":
                                                mp_01 = in_player_data["魔力"]["当前"]
                                                in_player_data["魔力"]["当前"] = in_player_data["魔力"]["当前最大"]
                                                mp_02 = in_player_data["魔力"]["当前"]
                                                txt += "[{}]回复全部魔力({}→{})".format(in_player_data["昵称"], mp_01, mp_02)


                            if effect["类型"] == "增益":
                                txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                attribute = effect["属性"].split("/")
                                buff_value = effect["数值"]
                                buff_level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "律者箴言"] or [0]
                                if buff_level[0] > 0:
                                    buff_value = int(buff_value * (1 + 0.1 * buff_level[0]))
                                    txt += "✨"
                                if any(effect["名称"] == "神力加持" for effect in player_data["效果"]):
                                    effect["回合"] = math.ceil(effect["回合"] * 1.3)
                                for atbt in attribute:
                                    for in_player_data in data["玩家"]:
                                        if in_player_data["uid"] == player_data["uid"]:
                                            buff_time = effect["回合"] + 1
                                        else:
                                            buff_time = effect["回合"]
                                        if in_player_data["生命"]["当前"] <= 0:
                                            continue
                                        in_player_data["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": atbt, "数值": buff_value, "回合": buff_time})
                                        txt += "\n[{}]的{}提升了！".format(in_player_data["昵称"], atbt)

                            if effect["类型"] == "净化":
                                txt += "\n#{}#".format(effect["名称"])
                                attribute = effect["属性"].split("/")
                                for atbt in attribute:
                                    if atbt == "所有":
                                        txt += "清除全队异常效果"
                                    elif atbt == "控制":
                                        txt += "清除全队控制效果"
                                    elif atbt == "流失":
                                        txt += "清除全队流失效果"
                                    else:
                                        txt += "清除全队{}效果".format(atbt)
                                for in_player_data in data["玩家"]:
                                    if in_player_data["生命"]["当前"] <= 0:
                                        continue
                                    for atbt in attribute:
                                        if atbt == "所有":
                                            in_player_data["效果"] = [in_player_data_effect for in_player_data_effect in in_player_data["效果"] if in_player_data_effect["类型"] != "控制"]
                                            in_player_data["效果"] = [in_player_data_effect for in_player_data_effect in in_player_data["效果"] if in_player_data_effect["类型"] != "流失"]
                                        elif atbt == "控制":
                                            in_player_data["效果"] = [in_player_data_effect for in_player_data_effect in in_player_data["效果"] if in_player_data_effect["类型"] != "控制"]
                                        elif atbt == "流失":
                                            in_player_data["效果"] = [in_player_data_effect for in_player_data_effect in in_player_data["效果"] if in_player_data_effect["类型"] != "流失"]
                                        else:
                                            in_player_data["效果"] = [in_player_data_effect for in_player_data_effect in in_player_data["效果"] if not (in_player_data_effect["类型"] == "流失" and in_player_data_effect["属性"] == atbt)]

                            if effect["类型"] == "驱散":
                                txt += "\n#{}#".format(effect["名称"])
                                attribute = effect["属性"].split("/")
                                for atbt in attribute:
                                    if atbt == "所有":
                                        txt += "清除全队减益效果"
                                    else:
                                        txt += "清除全队{}减益效果".format(atbt)
                                for in_player_data in data["玩家"]:
                                    if in_player_data["生命"]["当前"] <= 0:
                                        continue
                                    for atbt in attribute:
                                        if atbt == "所有":
                                            in_player_data["效果"] = [in_player_data_effect for in_player_data_effect in in_player_data["效果"] if in_player_data_effect["类型"] != "减益"]
                                        else:
                                            in_player_data["效果"] = [in_player_data_effect for in_player_data_effect in in_player_data["效果"] if not (in_player_data_effect["类型"] == "减益" and in_player_data_effect["属性"] == atbt)]
                                        
                            if effect["类型"] == "复活":
                                txt += "\n#{}#".format(effect["名称"])
                                if effect["属性"] == "所有":
                                    txt += "复苏全部倒地队友"
                                for in_player_data in data["玩家"]:
                                    if in_player_data["生命"]["当前"] > 0:
                                        continue
                                    in_player_data["效果"] = [in_player_data_effect for in_player_data_effect in in_player_data["效果"] if (in_player_data_effect["类型"] == "光环" or in_player_data_effect["类型"] == "被动" or in_player_data_effect["类型"] == "职业" or in_player_data_effect["类型"] == "装备")]
                                    in_player_data["效果"].append({"名称": effect["名称"], "类型": "获得", "属性": "物理减伤", "数值": 50, "回合": 1})
                                    in_player_data["效果"].append({"名称": effect["名称"], "类型": "获得", "属性": "魔法减伤", "数值": 50, "回合": 1})
                                    in_player_data["效果"].append({"名称": effect["名称"], "类型": "获得", "属性": "霸体", "数值": 100, "回合": 1})
                                    in_player_data["生命"]["当前"] = math.ceil(in_player_data["生命"]["最终"] * effect["数值"] / 100)
                                    in_player_data["魔力"]["当前"] = math.ceil(in_player_data["魔力"]["最终"] * effect["数值"] / 100)
                                    txt += "\n[{}]复苏了！".format(in_player_data["昵称"])

                            if effect["类型"] == "获得":
                                txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                attribute = effect["属性"].split("/")
                                for atbt in attribute:
                                    for in_player_data in data["玩家"]:
                                        if in_player_data["uid"] == player_data["uid"]:
                                            buff_time = effect["回合"] + 1
                                        else:
                                            buff_time = effect["回合"]
                                        if in_player_data["生命"]["当前"] <= 0:
                                            continue
                                        in_player_data["效果"].append({"名称": effect["名称"], "类型": "获得", "属性": atbt, "数值": effect["数值"], "回合": effect["回合"]})
                                        txt += "[{}]获得{}%{}！".format(in_player_data["昵称"], effect["数值"], atbt)



                        if effect["目标"] == "对方":

                            if effect["类型"] == "嘲讽":
                                txt += "\n#{}#[{}]的仇恨增加了！".format(effect["名称"], player_data["昵称"])
                                player_data["仇恨"] = int(player_data["仇恨"]) + int(player_data["物防"]["当前"]) * 10 + int(player_data["魔防"]["当前"]) * 10
                
                

                to_remove1 = [] 
                for status1 in player_data["效果"]:
                    if status1["类型"] == "职业":
                        if status1["名称"] == "巨人身躯":
                            player_data["仇恨"] = player_data["生命"]["当前"]
                    if status1["回合"] < 999:
                        status1["回合"] -= 1
                    if status1["回合"] <= 0:
                        to_remove1.append(status1)
                for status1 in to_remove1:
                    player_data["效果"].remove(status1)

                for skill_time in player_data["技能"]:
                    if skill_time.get("冷却", 0) > 0:
                        skill_time["冷却"] = int(skill_time["冷却"] - 1)
                

                player_data["出招"] = ""

            survivor_final = [sur for sur in data["玩家"] if sur["生命"]["当前"] > 0]
            monster_final = [sur for sur in data["敌人"] if sur["生命"]["当前"] > 0]
            if monster_final == [] or survivor_final == []:
                break

                
            #敌人回合
            if uid == 0:
                for item in data["敌人"]:
                    if item["uid"] == uid:
                        enemy_data = item
                        break
                enemy_status = enemy_data["效果"]
                for status2 in enemy_status:
                    if status2["类型"] == "流失":
                        if status2["属性"] == "最大生命百分比":
                            hp_01 = enemy_data["生命"]["当前"]
                            enemy_data["生命"]["当前"] -= math.floor(enemy_data["生命"]["当前最大"] * status2["数值"] / 1000)
                            if enemy_data["生命"]["当前"] < 0:
                                enemy_data["生命"]["当前"] = 0
                            hp_02 = enemy_data["生命"]["当前"]
                            txt += "\n${}$流失生命值({}→{})".format(status2["名称"], hp_01, hp_02)
                        if status2["属性"] == "当前生命百分比":
                            hp_01 = enemy_data["生命"]["当前"]
                            enemy_data["生命"]["当前"] -= math.floor(enemy_data["生命"]["当前"] * status2["数值"] / 1000)
                            if enemy_data["生命"]["当前"] < 0:
                                enemy_data["生命"]["当前"] = 0
                            hp_02 = enemy_data["生命"]["当前"]
                            txt += "\n${}$流失生命值({}→{})".format(status2["名称"], hp_01, hp_02)
                #检索boss
                #检索boss
                #检索boss
                enemy_name = enemy_data["昵称"]
                enemy_now_hp = enemy_data["生命"]["当前"]
                enemy_max_hp = enemy_data["生命"]["当前最大"]
                enemy_counter = enemy_data["计数器"]
                enemy_action = await boss_battle(enemy_name, bat_round, enemy_now_hp, enemy_max_hp, enemy_counter)
                enemy_skill_name = enemy_action.get("技能", "")
                enemy_aim = enemy_action.get("目标", "")
                enemy_word = enemy_action.get("描述", "")
                enemy_data["计数器"] = enemy_action.get("计数器", enemy_counter)
                if enemy_word != "":
                    txt += "\n{}".format(enemy_word)
                #检索boss
                #检索boss
                #检索boss
                if enemy_skill_name == "":
                    enemy_skill = random.choice(enemy_data["技能"])
                else:
                    for skil in enemy_data["技能"]:
                        if skil["名称"] == enemy_skill_name:
                            enemy_skill = skil
                            break

                skill_name = enemy_skill["名称"]
                skill_level = enemy_skill["等级"]
                with open(f"data/skills/{skill_name}.txt", 'r') as f:
                    skill_data = json.load(f)
                    skill_power = int(skill_data["威力"])
                    skill_class = skill_data["类别"]
                    skill_effect = skill_data["效果"]

                    aims = []
                    survivor = [sur for sur in data["玩家"] if sur["生命"]["当前"] > 0]
                    if enemy_aim == "":
                        if skill_data["对象"] == "单体":
                            if all(item["仇恨"] == 0 for item in survivor):
                                aim = random.randint(0, len(survivor)-1)
                            else:
                                weights = [item["仇恨"] for item in survivor]
                                aim = random.choices(range(len(survivor)), weights=weights)[0]
                            aims.append(aim)

                        if skill_data["对象"] == "全体":
                            for aim in range(len(survivor)):
                                if aim not in aims:
                                    aims.append(aim)
                    
                    elif enemy_aim == "全体":
                        for aim in range(len(survivor)):
                            if aim not in aims:
                                aims.append(aim)

                    elif enemy_aim == "仇恨最高":
                        aim = max(range(len(survivor)), key=lambda x: survivor[x]["仇恨"])
                        aims.append(aim)

                    elif enemy_aim == "仇恨最低":
                        aim = min(range(len(survivor)), key=lambda x: survivor[x]["仇恨"])
                        aims.append(aim)  

                    elif enemy_aim == "生命最高":
                        aim = max(range(len(survivor)), key=lambda x: survivor[x]["生命"]["当前"])
                        aims.append(aim)

                    elif enemy_aim == "生命最低":
                        aim = min(range(len(survivor)), key=lambda x: survivor[x]["生命"]["当前"])
                        aims.append(aim)

                
                txt += "\n【{}施放技能[{}]】".format(enemy_data["昵称"], skill_name)
                
                many_hit = 1
                if_unlimit_combo = False
                if skill_class == "物理":
                    for in_status in enemy_status:
                        if in_status.get("属性", "") == "无限连击":
                            many_hit = 99
                            txt += "\n#{}#无限连击！".format(in_status["名称"])
                            if_unlimit_combo = True
                            break
                
                for effect in skill_effect:
                    if effect["目标"] == "自身":
                        
                        if effect["类型"] == "必定":
                            if effect["属性"] == "命中":
                                txt += "\n#{}#必定命中！".format(effect["名称"])
                            elif effect["属性"] == "暴击":
                                txt += "\n#{}#必定暴击！".format(effect["名称"])

                        if effect["类型"] == "连击" and if_unlimit_combo == False:
                            if effect["属性"] == "相同":
                                many_hit = effect["数值"]
                                txt += "\n#{}#疾速{}连击！".format(effect["名称"], effect["数值"])
                        
                        if effect["类型"] == "提升":
                            txt += "\n#{}#{}提升{}%！".format(effect["名称"], effect["属性"], effect["数值"])
                        
                        


                for aim_survivor in aims:

                    try:
                        aim_id = survivor[aim_survivor]["uid"]
                    except IndexError:
                
                        txt += "\n【IndexError】\n【目标识别错误，当前目标索引[{}]/[{}]】".format(aim_survivor, len(survivor))
                        #索引出错修改#
                        #continue
                    for aim, aim_player in enumerate(data["玩家"]):
                        if aim_player["uid"] == aim_id:
                            break

                    #计算命中暴击暴伤  
                    """等级压制"""
                    difference = enemy_data["等级"] - data["玩家"][aim]["等级"]
                    if difference <= 2 and difference >= -2:
                        press = 0
                        harm_press = 1
                    elif difference > 2:
                        press = difference - 2
                        harm_press = 1.1 ** press
                        txt += "\n⚠︎造成威压⚠︎"
                    elif difference < -2:
                        press = -(difference + 2)
                        harm_press = 0.9 ** press

                    enemy_data["命中"]["当前"] *= harm_press
                    enemy_data["暴击"]["当前"] *= harm_press
                    enemy_data["暴伤"]["当前"] *= harm_press

                    for effect in skill_effect:
                        if effect["目标"] == "自身":
                            if effect["类型"] == "提升":
                                enemy_data[effect["属性"]]["当前"] *= (100 + effect["数值"]) / 100
                    
                    for x_hit in range(many_hit):
                        
                        if data["玩家"][aim]["生命"]["当前"] == 0:
                            continue

                        hit_percent = 1 - 0.5 ** (enemy_data["命中"]["当前"] / data["玩家"][aim]["闪避"]["当前"])

                        if enemy_data["最低命中率"]["当前"] + data["玩家"][aim]["最低闪避率"]["当前"] >= 100:
                            min_hit_percent = enemy_data["最低命中率"]["当前"] / (enemy_data["最低命中率"]["当前"] + data["玩家"][aim]["最低闪避率"]["当前"])
                            hit_percent = min_hit_percent
                        elif hit_percent < enemy_data["最低命中率"]["当前"] / 100:
                            hit_percent < enemy_data["最低命中率"]["当前"] / 100
                        elif hit_percent > 1 - data["玩家"][aim]["最低闪避率"]["当前"] / 100:
                            hit_percent = 1 - data["玩家"][aim]["最低闪避率"]["当前"] / 100
                        

                        if if_unlimit_combo:
                            enemy_data["命中"]["当前"] *= 0.5

                        crit_percent = 1 - 0.5 ** (enemy_data["暴击"]["当前"] / data["玩家"][aim]["暴免"]["当前"])
                    
                        x = enemy_data["暴伤"]["当前"] / data["玩家"][aim]["暴抗"]["当前"]
                        if x < 1:
                            crit_harm = 1 + x
                        else:
                            crit_harm = 2 + math.log(x, 3)
                    
                        if crit_harm > 3 and enemy_data["一转"] != "法师":
                            crit_harm = 3
                        if random.random() <= hit_percent:
                            if_hit = True
                        else:
                            if_hit = False
                        if random.random() <= crit_percent:
                            if_crit = True
                        else:
                            if_crit = False

                        
                        for effect in skill_effect:
                            if effect["目标"] == "自身":
                                if effect["类型"] == "必定":
                                    if effect["属性"] == "命中":
                                        if_hit = True
                                    if effect["属性"] == "暴击":
                                        if_crit = True
                        
                        """穿透计算"""
                        """穿透计算"""
                        """穿透计算"""
                        true_defend = data["玩家"][aim]["物防"]["当前"] * (100 - enemy_data["物理穿透"]["当前"]) / 100
                        true_magic_defend = data["玩家"][aim]["魔防"]["当前"] * (100 - enemy_data["魔法穿透"]["当前"]) / 100
                        """穿透计算"""
                        """穿透计算"""
                        """穿透计算"""

                        if skill_class == "物理":
                            if_ad_attack = True
                            if_ap_attack = False
                            harm = enemy_data["物攻"]["当前"] * (skill_power / 100) * enemy_data["物攻"]["当前"] * (skill_power / 100)/ (enemy_data["物攻"]["当前"] * (skill_power / 100) + true_defend)
                            harm *= ((100 + enemy_data["物理增伤"]["当前"]) / 100)
                            harm *= ((100 - data["玩家"][aim]["物理减伤"]["当前"]) / 100)
                            buff_skill = False

                        elif skill_class == "魔法":
                            if_ap_attack = True
                            if_ad_attack = False
                            true_magic_defend = data["玩家"][aim]["魔防"]["当前"]
                            harm = enemy_data["魔攻"]["当前"] * (skill_power / 100) * enemy_data["魔攻"]["当前"] * (skill_power / 100)/ (enemy_data["魔攻"]["当前"] * (skill_power / 100) + true_magic_defend)
                            harm *= ((100 + enemy_data["魔法增伤"]["当前"]) / 100)
                            harm *= ((100 - data["玩家"][aim]["魔法减伤"]["当前"]) / 100)
                            buff_skill = False

                        elif skill_class == "属性":
                            harm = 0
                            if_hit = True
                            buff_skill = True

                        if if_crit:
                            harm *= crit_harm

                        if if_hit and buff_skill == False:
                            harm *= random.uniform(0.9, 1.1)
                            txt11 = ""
                            for effect in skill_effect:
                                if effect["目标"] == "自身":
                                    if effect["类型"] == "伤害":
                                        txt11 += "\n#{}#".format(effect["名称"])
                                        attribute = effect["属性"]
                                        if attribute == "增幅":
                                            harm_up = harm * effect["数值"] / 100
                                            harm += harm_up
                                            if effect["数值"] <=20:
                                                word = "小幅"
                                            elif effect["数值"] > 20 and effect["数值"] <= 40:
                                                word = "中幅"
                                            elif effect["数值"] > 40 and effect["数值"] <= 60:
                                                word = "大幅"
                                            elif effect["数值"] > 60 and effect["数值"] <= 80:
                                                word = "巨大幅"
                                            elif effect["数值"] > 80 and effect["数值"] <= 100:
                                                word = "极大幅"
                                            elif effect["数值"] > 100:
                                                word = "超幅"
                                            txt11 += "本次伤害{}提升({})".format(word, math.floor(harm_up))
                                        elif attribute == "附加攻击百分比":
                                            harm_up = (enemy_data["物攻"]["当前"] + enemy_data["魔攻"]["当前"]) * effect["数值"] / 100
                                            harm += harm_up
                                            if effect["数值"] <=20:
                                                word = "小幅"
                                            elif effect["数值"] > 20 and effect["数值"] <= 40:
                                                word = "中幅"
                                            elif effect["数值"] > 40 and effect["数值"] <= 60:
                                                word = "大幅"
                                            elif effect["数值"] > 60 and effect["数值"] <= 80:
                                                word = "巨大幅"
                                            elif effect["数值"] > 80 and effect["数值"] <= 100:
                                                word = "极大幅"
                                            elif effect["数值"] > 100:
                                                word = "超幅"
                                            txt11 += "附加{}面板伤害({})".format(word, math.floor(harm_up))
                                        elif attribute == "血肉拥抱":
                                            harm_up = 0
                                            for passive_effect in data["玩家"][aim]["效果"]:
                                                if passive_effect["名称"] == "古神血脉":
                                                    harm_up += int(passive_effect["数值"] * passive_effect["回合"])
                                            harm_up = math.ceil(harm_up * effect["数值"] / 100)
                                            harm += harm_up
                                            if effect["数值"] <=20:
                                                word = "小幅"
                                            elif effect["数值"] > 20 and effect["数值"] <= 40:
                                                word = "中幅"
                                            elif effect["数值"] > 40 and effect["数值"] <= 60:
                                                word = "大幅"
                                            elif effect["数值"] > 60 and effect["数值"] <= 80:
                                                word = "巨大幅"
                                            elif effect["数值"] > 80 and effect["数值"] <= 100:
                                                word = "极大幅"
                                            elif effect["数值"] > 100:
                                                word = "超幅"
                                            txt11 += "伤害提升{}".format(harm_up)


                            harm *= harm_press
                            


                            txt += "\n◈"
                            if if_unlimit_combo:
                                txt += "✦{}连✦".format(x_hit + 1)

                            if if_crit:
                                txt += "[暴击!]"
                            else:
                                txt += ""
                            
                            if_法力洪流 = False
                            if any(job_effect["名称"] == "法力洪流" for job_effect in data["玩家"][aim]["效果"]):
                                if_法力洪流 = True
                                reduce_harm_percent = data["玩家"][aim]["魔力"]["当前"] / data["玩家"][aim]["魔力"]["当前最大"]
                                harm_reduce = math.ceil(reduce_harm_percent * harm)
                                data["玩家"][aim]["魔力"]["当前"] -= harm_reduce
                                harm -= harm_reduce
                                txt_法力洪流 = "\n#法力洪流#减免{}伤害".format(harm_reduce)
    
                            skill_fangfan = False
                            if any(passive_effect["类型"] == "防反" for passive_effect in data["玩家"][aim]["效果"]):
                                skill_fangfan = True
                                for passive_effect in data["玩家"][aim]["效果"]:
                                    if passive_effect["类型"] == "防反":
                                        skill_atk = (data["玩家"][aim]["物防"]["当前"] + data["玩家"][aim]["魔防"]["当前"]) / 2 * passive_effect["数值"] / 100
                                        skill_harm = int((skill_atk * skill_atk / (skill_atk + enemy_data["物防"]["当前"]) + harm / 4) / harm_press)
                                        skill_harm *= (100 - enemy_data["物理减伤"]["当前"]) / 100
                                        skill_harm = math.ceil(skill_harm)
                                        harm = harm * 3 / 4
                                        if harm <=1:
                                            harm = 1
                                        enemy_hp11 = enemy_data["生命"]["当前"]
                                        enemy_data["生命"]["当前"] = enemy_data["生命"]["当前"] - skill_harm
                                        if enemy_data["生命"]["当前"] < 0:
                                            enemy_data["生命"]["当前"] = 0
                                        enemy_hp12 = enemy_data["生命"]["当前"]
                                        break

                            equip_shanbeng = False
                            if any(equip_effect["名称"] == "山崩" for equip_effect in data["玩家"][aim]["效果"]):
                                equip_percent = 0.5 - data["玩家"][aim]["生命"]["当前"] / data["玩家"][aim]["生命"]["当前最大"] * 0.45
                                rand_num = random.random()
                                if rand_num <= equip_percent:
                                    equip_shanbeng = True
                                    equip_harm = int(((data["玩家"][aim]["生命"]["当前最大"] - data["玩家"][aim]["生命"]["当前"]) * data["玩家"][aim]["生命"]["当前"] / data["玩家"][aim]["生命"]["当前最大"] / 4) / harm_press)
                                    enemy_hp21 = enemy_data["生命"]["当前"]
                                    enemy_data["生命"]["当前"] = enemy_data["生命"]["当前"] - equip_harm
                                    if enemy_data["生命"]["当前"] < 0:
                                        enemy_data["生命"]["当前"] = 0
                                    enemy_hp22 = enemy_data["生命"]["当前"]

                            equip_anti = False
                            if any("反震" in passive_effect["名称"] for passive_effect in data["玩家"][aim]["效果"]) and if_ad_attack == True:
                                equip_anti = True
                                for passive_effect in data["玩家"][aim]["效果"]:
                                    if "反震" in passive_effect["名称"]:
                                        anti_harm = (enemy_data["物攻"]["当前"] * (skill_power / 100) * enemy_data["物攻"]["当前"] * (skill_power / 100)/ (enemy_data["物攻"]["当前"] * (skill_power / 100) + enemy_data["物防"]["当前"])) * passive_effect["数值"] / 100
                                        anti_harm *= (100 - enemy_data["物理减伤"]["当前"]) / 100
                                        anti_harm = math.ceil(anti_harm)
                                        if anti_harm < 1:
                                            anti_harm = 1
                                        enemy_hp31 = enemy_data["生命"]["当前"]
                                        enemy_data["生命"]["当前"] = enemy_data["生命"]["当前"] - anti_harm
                                        if enemy_data["生命"]["当前"] < 0:
                                            enemy_data["生命"]["当前"] = 0
                                        enemy_hp32 = enemy_data["生命"]["当前"]
                                        break


                            if_found_titan = False
                            if if_have_titan and data["玩家"][aim]["uid"] not in titan_uid:
                                for titan_x in titan_uid:
                                    if if_titan_share and titan_share_uid[0] != titan_x:
                                        continue
                                    for in_player_data in data["玩家"]:
                                        if in_player_data["uid"] == titan_x:
                                            if in_player_data["生命"]["当前"] > 0:
                                                if if_titan_share:
                                                    harm_reduce = math.ceil(harm * 0.75)
                                                    run_blood_harm = math.ceil(harm * 0.75 * 0.33)
                                                    harm *= 0.25
                                                    in_player_data["累计承伤"] += harm_reduce
                                                    txt_titan1 = "$挺身$[{}]承担{}伤害".format(in_player_data["昵称"], harm_reduce)
                                                else:
                                                    harm_reduce = math.ceil(harm * 0.25)
                                                    run_blood_harm = math.ceil(harm * 0.25 * 0.33)
                                                    harm *= 0.75
                                                    in_player_data["累计承伤"] += harm_reduce
                                                    txt_titan1 = "\n$庞大身躯$[{}]承担{}伤害".format(in_player_data["昵称"], harm_reduce)
                                                in_player_data["效果"].append({"名称": "古神血脉", "类型": "流失", "属性": "固定生命值", "数值": run_blood_harm, "回合": 3})
                                                txt_titan1 += "\n$古神血脉$转为生命流失{}({})".format(run_blood_harm, 3)
                                                if_found_titan = True
                                                break
                                    if if_found_titan:
                                        break
                            
                            is_titan = False
                            if data["玩家"][aim]["uid"] in titan_uid:
                                is_titan = True
                                run_blood_harm = math.ceil(harm * 0.33)
                                if run_blood_harm <=1:
                                    run_blood_harm = 1
                                harm = 1
                                data["玩家"][aim]["累计承伤"] += run_blood_harm * 3
                                txt_titan2 = "\n$古神血脉$转为生命流失{}({})".format(run_blood_harm, 3)
                                data["玩家"][aim]["效果"].append({"名称": "古神血脉", "类型": "流失", "属性": "固定生命值", "数值": run_blood_harm, "回合": effect["回合"]})



                            harm = math.floor(harm)
                            if harm <=1:
                                harm = 1

                            if_replace_die = False
                            if harm > data["玩家"][aim]["生命"]["当前"] and data["玩家"][aim].get("二转", "") == "影忍":
                                for in_player_data in data["玩家"]:
                                    if in_player_data.get("主人uid", "") == data["玩家"][aim]["uid"]:
                                        if_replace_die = True
                                        txt_假死替身 = "\n#假死替身#转移了此伤害！"
                                        in_player_data["生命"]["当前"] -= harm
                                        break
                                    
                            

                            data["玩家"][aim]["累计承伤"] += harm

                            if if_replace_die:
                                harm = 0

                            txt += "对[{}]造成了{}点伤害".format(data["玩家"][aim]["昵称"], harm)
                            hp_1 = data["玩家"][aim]["生命"]["当前"]
                            data["玩家"][aim]["生命"]["当前"] -= harm
                            hp_2 = data["玩家"][aim]["生命"]["当前"]
                            if hp_2 < 0:
                                hp_2 = 0
                                data["玩家"][aim]["生命"]["当前"] = 0
                                if await txt_exist("player", "number", number, "状态") == "教程5":
                                    hp_2 = 1
                                    data["玩家"][aim]["生命"]["当前"] = 1


                            txt += "({}→{})".format(hp_1, hp_2)
                            txt += txt11

                            if if_replace_die:
                                txt += txt_假死替身
                            if if_法力洪流:
                                txt += txt_法力洪流
                            if if_found_titan:
                                txt += txt_titan1
                            elif is_titan:
                                txt += txt_titan2

                            for status3 in enemy_status:
                                if status3["类型"] == "嗜血" and enemy_data["生命"]["当前"] != 0:
                                    if status3["属性"] == "伤害":
                                        hp_absorb = int(harm * status3["数值"] / 100)
                                        hp_now = int(enemy_data["生命"]["当前"])
                                        hp_now0 = hp_now
                                        hp_max = int(enemy_data["生命"]["当前最大"])
                                        hp_now += hp_absorb
                                        if hp_now > hp_max:
                                            hp_now = hp_max
                                        enemy_data["生命"]["当前"] = int(hp_now)
                                        txt += "\n#嗜血#生命汲取{}({}→{})".format(hp_absorb, hp_now0, enemy_data["生命"]["当前"])

                        
                            if skill_fangfan:
                                txt += "\n🛡$防反$受到{}点伤害({}→{})".format(skill_harm, enemy_hp11, enemy_hp12)
                            if equip_shanbeng:
                                txt += "\n🌋$山崩$受到{}点伤害({}→{})".format(equip_harm, enemy_hp21, enemy_hp22)
                            if equip_anti:
                                txt += "\n🦔$反震$受到{}点伤害({}→{})".format(anti_harm, enemy_hp31, enemy_hp32)
                        

                            for effect in skill_effect:
                                if effect["目标"] == "对方":
                                    if effect["类型"] == "增益":
                                        txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                        attribute = effect["属性"].split("/")
                                        for atbt in attribute:
                                            data["玩家"][aim]["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": atbt, "数值": effect["数值"], "回合": effect["回合"]})
                                            txt += "[{}]的{}提升了！".format(data["玩家"][aim]["昵称"], atbt)
    
                                    elif effect["类型"] == "减益":
                                        txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                        attribute = effect["属性"].split("/")
                                        for atbt in attribute:
                                            data["玩家"][aim]["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": atbt, "数值": effect["数值"], "回合": effect["回合"]})
                                            data["玩家"][aim][atbt]["当前"] *= (100 - effect["数值"]) / 100
                                            txt += "[{}]的{}降低了！".format(data["玩家"][aim]["昵称"], atbt)

                                    elif effect["类型"] == "流失":
                                        txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                        attribute = effect["属性"].split("/")
                                        for atbt in attribute:
                                            if_found = False
                                            for in_player_data_effect in data["玩家"][aim]["效果"]:
                                                if in_player_data_effect["名称"] == effect["名称"] and in_player_data_effect["属性"] == effect["属性"] and in_player_data_effect["回合"] == effect["回合"]:
                                                    if_found = True
                                                    in_player_data_effect["数值"] += effect["数值"]
                                                    break
                                            if not if_found:
                                                data["玩家"][aim]["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": atbt, "数值": effect["数值"], "回合": effect["回合"]})
                                            txt += "[{}]持续流失{}！".format(data["玩家"][aim]["昵称"], atbt)

                                    elif effect["类型"] == "控制":
                                        control_number1 = data["玩家"][aim]["韧性"]["当前"] // (enemy_data["等级"] * 100)
                                        control_number2 = data["玩家"][aim]["韧性"]["当前"] % (enemy_data["等级"] * 100) / (enemy_data["等级"] * 100)
                                        control_percent = 0
                                        control_percent_add = 10
                                        for control_number_x in range(control_number1):
                                            control_percent += control_percent_add
                                            control_percent_add *= 0.9
                                        control_percent += control_percent_add * control_number2

                                        txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                        attribute = effect["属性"].split("/")
                                        for atbt in attribute:
                                            attribute_random = random.random() * 100
                                            tough_random = random.random() * 100
                                            if any(no_control_effect.get("属性", "") == "霸体" for no_control_effect in data["玩家"][aim]["效果"]):
                                                txt += "[{}][霸体]".format(data["玩家"][aim]["昵称"])
                                                break
                                            elif attribute_random > int(effect["数值"]):
                                                txt += "[{}][未生效]".format(data["玩家"][aim]["昵称"])
                                                break
                                            elif tough_random < control_percent:
                                                txt += "[{}][抵抗]".format(data["玩家"][aim]["昵称"])
                                                break

                                            data["玩家"][aim]["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": atbt, "数值": effect["数值"], "回合": effect["回合"]})
                                            txt += "[{}]进入{}状态！".format(data["玩家"][aim]["昵称"], atbt)

                    
                                
                            

                            
                        elif buff_skill == False:
                            harm = 0
                            level = [skill["等级"] for skill in player_data["效果"] if skill["名称"] == "杀意感知"] or [0]
                            if level[0] > 0:
                                for skill in data["玩家"][aim]["效果"]:
                                    if skill["名称"] == "杀意感知":
                                        skill["层数"] += 1
                            txt += "\n◈[Miss]被{}闪避了！".format(data["玩家"][aim]["昵称"])
                            if if_unlimit_combo == True:
                                break


                        survivor_final = [sur for sur in data["玩家"] if sur["生命"]["当前"] > 0]
                        monster_final = [sur for sur in data["敌人"] if sur["生命"]["当前"] > 0]
                        if survivor_final == [] or monster_final == []:
                            break
                    
                    if survivor_final == [] or monster_final == []:
                        break
                #修改处#
                if buff_skill == True or buff_skill == False:
                    for effect in skill_effect:
                        if effect["目标"] == "自身":  
                            buff_time = effect["回合"] + 1          
                            if effect["类型"] == "回复":
                                txt += "\n#{}#".format(effect["名称"])
                                cure_percent = effect["数值"]
                                cure_value = enemy_data["魔攻"]["当前"] * cure_percent / 100 * len(data["玩家"])
                                cure_number = int(cure_value)
                                hp_01 = int(enemy_data["生命"]["当前"])
                                enemy_data["生命"]["当前"] = hp_01 + cure_number
                                if enemy_data["生命"]["当前"] > enemy_data["生命"]["当前最大"]:
                                    enemy_data["生命"]["当前"] = enemy_data["生命"]["当前最大"]
                                hp_02 = int(enemy_data["生命"]["当前"])
                                txt += "[{}]回复生命{}({}→{})".format(enemy_data["昵称"], cure_number, hp_01, hp_02)

                            if effect["类型"] == "增益":
                                txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                attribute = effect["属性"].split("/")
                                for atbt in attribute:
                                    enemy_data["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": atbt, "数值": effect["数值"], "回合": buff_time})
                                    txt += "[{}]的{}提升了！".format(enemy_data["昵称"], atbt)

                            if effect["类型"] == "减益":
                                txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                attribute = effect["属性"].split("/")
                                for atbt in attribute:
                                    enemy_data["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": atbt, "数值": effect["数值"], "回合": buff_time})
                                    txt += "[{}]的{}降低了！".format(enemy_data["昵称"], atbt)

                            if effect["类型"] == "获得":
                                txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                attribute = effect["属性"].split("/")
                                for atbt in attribute:
                                    enemy_data["效果"].append({"名称": effect["名称"], "类型": "获得", "属性": atbt, "数值": effect["数值"], "回合": buff_time})
                                    txt += "[{}]获得{}%{}！".format(enemy_data["昵称"], effect["数值"], atbt)

                            if effect["类型"] == "嗜血":
                                txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                if not any(eff["类型"] == "嗜血" for eff in enemy_data["效果"]):
                                    enemy_data["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": effect["属性"], "数值": effect["数值"], "回合": buff_time})
                                    txt += "[{}]获得伤害汲取！".format(enemy_data["昵称"])
                                else:
                                    for eff in enemy_data["效果"]:
                                        if eff["类型"] == "嗜血":
                                            eff["回合"] = buff_time
                                            break
                                    txt += "[{}]获得伤害汲取！".format(enemy_data["昵称"])

                            if effect["类型"] == "防反":
                                txt += "\n#{}#({})".format(effect["名称"], effect["回合"])
                                if not any(eff["类型"] == "防反" for eff in enemy_data["效果"]):
                                    enemy_data["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": effect["属性"], "数值": effect["数值"], "回合": buff_time})
                                    txt += "[{}]进入防御反击姿态！".format(enemy_data["昵称"])
                                else:
                                    for eff in enemy_data["效果"]:
                                        if eff["类型"] == "防反":
                                            eff["回合"] = buff_time
                                            break
                                    txt += "[{}]持续防御反击姿态！".format(enemy_data["昵称"])
                            
                        if effect["目标"] == "我方群体":
                            for in_enemy_data in data["敌人"]:
                                if in_enemy_data["uid"] == enemy_data["uid"]:
                                    buff_time = effect["回合"] + 1
                                else:
                                    buff_time = effect["回合"]
                                if effect["类型"] == "回复":
                                    txt += "\n#{}#".format(effect["名称"])
                                    cure_percent = effect["数值"]
                                    cure_value = enemy_data["魔攻"]["当前"] * cure_percent / 100 * len(data["玩家"])
                                    cure_number = int(cure_value)
                                    hp_01 = in_enemy_data["生命"]["当前"]
                                    in_enemy_data["生命"]["当前"] += cure_number
                                    if in_enemy_data["生命"]["当前"] > in_enemy_data["生命"]["当前最大"]:
                                        in_enemy_data["生命"]["当前"] = in_enemy_data["生命"]["当前最大"]
                                    hp_02 = in_enemy_data["生命"]["当前"]
                                    txt += "[{}]回复生命{}({}→{})".format(in_enemy_data["昵称"], cure_number, hp_01, hp_02)
                                if effect["类型"] == "增益":
                                    txt += "\n#{}#({})".format(effect["名称"], buff_time)
                                    attribute = effect["属性"].split("/")
                                    for atbt in attribute:
                                        in_enemy_data["效果"].append({"名称": effect["名称"], "类型": effect["类型"], "属性": atbt, "数值": effect["数值"], "回合": buff_time})
                                        txt += "[{}]的{}提升了！".format(in_enemy_data["昵称"], atbt)

                        if effect["目标"] == "对方":
                            for in_player_data in data["玩家"]:
                                if effect["类型"] == "标记":
                                    if any(in_player["名称"] == effect["属性"] for in_player in in_player_data["效果"]):
                                        for in_player in in_player_data["效果"]:
                                            if in_player["名称"] == effect["属性"]:
                                                in_player["层数"] += effect["数值"]
                                    else:
                                        in_player_data["效果"].append({"名称": effect["属性"], "类型": "标记", "层数": effect["数值"], "回合": effect["回合"]})





                to_remove2 = []
                for status2 in enemy_data["效果"]:
                    status2["回合"] -= 1
                    if status2["回合"] == 0:
                        to_remove2.append(status2)
                for status2 in to_remove2:
                    enemy_data["效果"].remove(status2)
                        

                for player_仇恨 in data["玩家"]:
                    if player_仇恨.get("二转", "无") == "泰坦":
                        continue
                    else:
                        player_仇恨["仇恨"] = math.ceil(player_仇恨["仇恨"] / 2)
            

            #属性刷新
            for uid_data in data["玩家"]:
                if uid_data.get("主人uid", "") != "" and uid_data["生命"]["当前"] <= 0:
                    data["玩家"].remove(uid_data)
                最大生命 = 1
                最大魔力 = 1
                物攻 = 1
                魔攻 = 1
                物防 = 1
                魔防 = 1
                命中 = 1
                闪避 = 1
                暴击 = 1
                暴伤 = 1
                暴免 = 1
                暴抗 = 1
                韧性 = 1
                速度 = 1
                uid_data["物理减伤"]["当前"] = uid_data["物理减伤"]["基础"]
                uid_data["魔法减伤"]["当前"] = uid_data["魔法减伤"]["基础"]
                uid_data["物理增伤"]["当前"] = uid_data["物理增伤"]["基础"]
                uid_data["魔法增伤"]["当前"] = uid_data["魔法增伤"]["基础"]
                uid_data["物理穿透"]["当前"] = uid_data["物理穿透"]["基础"]
                uid_data["魔法穿透"]["当前"] = uid_data["魔法穿透"]["基础"]
                uid_data["生命回复"]["当前"] = uid_data["生命回复"]["基础"]
                uid_data["魔力回复"]["当前"] = uid_data["魔力回复"]["基础"]

                if uid_data["生命"]["当前"] <= 0:
                    uid_data["效果"] = [in_uid_data_effect for in_uid_data_effect in uid_data["效果"] if (in_uid_data_effect["类型"] != "获得" and in_uid_data_effect["类型"] != "增益" and in_uid_data_effect["类型"] != "减益" and in_uid_data_effect["类型"] != "控制")]

                flow_effect = []
                for effect_list in uid_data["效果"]:
                    if effect_list["类型"] == "增益":
                        if effect_list["属性"] == "最大生命":
                            最大生命 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "最大魔力":
                            最大魔力 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "物攻":
                            物攻 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "魔攻":
                            魔攻 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "物防":
                            物防 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "魔防":
                            魔防 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "命中":
                            命中 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "闪避":
                            闪避 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴击":
                            暴击 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴伤":
                            暴伤 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴免":
                            暴免 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴抗":
                            暴抗 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "韧性":
                            韧性 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "速度":
                            速度 *= (100 + effect_list["数值"]) / 100
                    elif effect_list["类型"] == "减益":
                        if effect_list["属性"] == "最大生命":
                            最大生命 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "最大魔力":
                            最大魔力 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "物攻":
                            物攻 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "魔攻":
                            魔攻 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "物防":
                            物防 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "魔防":
                            魔防 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "命中":
                            命中 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "闪避":
                            闪避 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴击":
                            暴击 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴伤":
                            暴伤 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴免":
                            暴免 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴抗":
                            暴抗 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "韧性":
                            韧性 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "速度":
                            速度 *= (100 - effect_list["数值"]) / 100
                    elif effect_list["类型"] == "获得":
                        if effect_list["属性"] == "物理减伤":
                            uid_data["物理减伤"]["当前"] = round(float((1 - (100 - uid_data["物理减伤"]["当前"]) * (100 - float(effect_list["数值"])) / 10000) * 100), 2)
                        elif effect_list["属性"] == "魔法减伤":
                            uid_data["魔法减伤"]["当前"] = round(float((1 - (100 - uid_data["魔法减伤"]["当前"]) * (100 - float(effect_list["数值"])) / 10000) * 100), 2)
                        elif effect_list["属性"] == "物理增伤":
                            uid_data["物理增伤"]["当前"] += round(effect_list["数值"])
                        elif effect_list["属性"] == "魔法增伤":
                            uid_data["魔法增伤"]["当前"] += round(effect_list["数值"])
                        elif effect_list["属性"] == "物理穿透":
                            uid_data["物理穿透"]["当前"] = round(float((1 - (100 - uid_data["物理穿透"]["当前"]) * (100 - float(effect_list["数值"])) / 10000) * 100), 2)
                        elif effect_list["属性"] == "魔法穿透":
                            uid_data["魔法穿透"]["当前"] = round(float((1 - (100 - uid_data["魔法穿透"]["当前"]) * (100 - float(effect_list["数值"])) / 10000) * 100), 2)
                        elif effect_list["属性"] == "生命回复":
                            uid_data["生命回复"]["当前"] = round(float((1 - (100 - uid_data["生命回复"]["当前"]) * (100 - float(effect_list["数值"])) / 10000) * 100), 2)
                        elif effect_list["属性"] == "魔力回复":
                            uid_data["魔力回复"]["当前"] = round(float((1 - (100 - uid_data["魔力回复"]["当前"]) * (100 - float(effect_list["数值"])) / 10000) * 100), 2)


                uid_data["物攻"]["当前"] = max(math.ceil(uid_data["物攻"]["最终"] * 物攻), 1)
                uid_data["魔攻"]["当前"] = max(math.ceil(uid_data["魔攻"]["最终"] * 魔攻), 1)
                uid_data["生命"]["当前最大"] = max(math.ceil(uid_data["生命"]["最终"] * 最大生命), 1)
                uid_data["魔力"]["当前最大"] = max(math.ceil(uid_data["魔力"]["最终"] * 最大魔力), 1)
                uid_data["物攻"]["当前"] = max(math.ceil(uid_data["物攻"]["最终"] * 物攻), 1)
                uid_data["魔攻"]["当前"] = max(math.ceil(uid_data["魔攻"]["最终"] * 魔攻), 1)
                uid_data["物防"]["当前"] = max(math.ceil(uid_data["物防"]["最终"] * 物防), 1)
                uid_data["魔防"]["当前"] = max(math.ceil(uid_data["魔防"]["最终"] * 魔防), 1)
                uid_data["命中"]["当前"] = max(math.ceil(uid_data["命中"]["最终"] * 命中), 1)
                uid_data["闪避"]["当前"] = max(math.ceil(uid_data["闪避"]["最终"] * 闪避), 1)
                uid_data["暴击"]["当前"] = max(math.ceil(uid_data["暴击"]["最终"] * 暴击), 1)
                uid_data["暴伤"]["当前"] = max(math.ceil(uid_data["暴伤"]["最终"] * 暴伤), 1)
                uid_data["暴免"]["当前"] = max(math.ceil(uid_data["暴免"]["最终"] * 暴免), 1)
                uid_data["暴抗"]["当前"] = max(math.ceil(uid_data["暴抗"]["最终"] * 暴抗), 1)
                uid_data["韧性"]["当前"] = max(math.ceil(uid_data["韧性"]["最终"] * 韧性), 1)
                uid_data["速度"]["当前"] = max(math.ceil(uid_data["速度"]["最终"] * 速度), 1)

                for effect_list in uid_data["效果"]:
                    if effect_list["类型"] == "被动":
                        if effect_list["名称"] == "杀意感知":
                            uid_data["速度"]["当前"] = math.ceil(uid_data["速度"]["当前"] * (1 + 0.02 * effect_list["等级"] * effect_list["层数"]))
                        if effect_list["名称"] == "不灭意志":
                            job_effect_percent = (uid_data["生命"]["当前最大"] - uid_data["生命"]["当前"]) / uid_data["生命"]["当前最大"] * 2
                            if job_effect_percent <= 1:
                                uid_data["生命回复"]["当前"] = round(float((1 - (100 - uid_data["生命回复"]["当前"]) * (100 - float(uid_data["生命回复"]["当前"] * job_effect_percent)) / 10000) * 100), 2)
                            else:
                                job_effect_0 = item["生命回复"]["当前"]
                                job_effect_1 = round(float((1 - (100 - item["生命回复"]["当前"]) * (100 - float(item["生命回复"]["当前"])) / 10000) * 100), 2)
                                uid_data["生命回复"]["当前"] = round(float((1 - (100 - job_effect_1) * (100 - float(job_effect_0 * (job_effect_percent - 1))) / 10000) * 100), 2)
                    
                    
                    if effect_list["类型"] == "职业":
                        if effect_list["名称"] == "法力洪流":
                            job_effect_percent = (uid_data["魔力"]["当前最大"] - uid_data["魔力"]["当前"]) / uid_data["魔力"]["当前最大"]
                            uid_data["魔力回复"]["当前"] = round(float((1 - (100 - uid_data["魔力回复"]["当前"]) * (100 - float(uid_data["魔力回复"]["当前"] * job_effect_percent)) / 10000) * 100), 2)


                    if effect_list["类型"] == "装备":
                        if effect_list["名称"] == "黎明":
                            uid_data["物攻"]["当前"] = math.ceil(uid_data["物攻"]["当前"] * (1 + 0.005 * effect_list["层数"]))
                            uid_data["魔攻"]["当前"] = math.ceil(uid_data["魔攻"]["当前"] * (1 + 0.005 * effect_list["层数"]))
                            uid_data["命中"]["当前"] = math.ceil(uid_data["命中"]["当前"] * (1 + 0.01 * effect_list["层数"]))
                            uid_data["速度"]["当前"] = math.ceil(uid_data["速度"]["当前"] * (1 + 0.01 * effect_list["层数"]))
                            uid_data["暴击"]["当前"] = math.ceil(uid_data["暴击"]["当前"] * (1 + 0.01 * effect_list["层数"]))
                            uid_data["暴伤"]["当前"] = math.ceil(uid_data["暴伤"]["当前"] * (1 + 0.01 * effect_list["层数"]))

                if uid_data["生命"]["当前"] > uid_data["生命"]["当前最大"]:
                    uid_data["生命"]["当前"] = uid_data["生命"]["当前最大"]
                if uid_data["魔力"]["当前"] > uid_data["魔力"]["当前最大"]:
                    uid_data["魔力"]["当前"] = uid_data["魔力"]["当前最大"]

            for uid_data in data["敌人"]:
                最大生命 = 1
                最大魔力 = 1
                物攻 = 1
                魔攻 = 1
                物防 = 1
                魔防 = 1
                命中 = 1
                闪避 = 1
                暴击 = 1
                暴伤 = 1
                暴免 = 1
                暴抗 = 1
                韧性 = 1
                速度 = 1
                uid_data["物理减伤"]["当前"] = uid_data["物理减伤"]["基础"]
                uid_data["魔法减伤"]["当前"] = uid_data["魔法减伤"]["基础"]
                uid_data["物理增伤"]["当前"] = uid_data["物理增伤"]["基础"]
                uid_data["魔法增伤"]["当前"] = uid_data["魔法增伤"]["基础"]
                uid_data["物理穿透"]["当前"] = uid_data["物理穿透"]["基础"]
                uid_data["魔法穿透"]["当前"] = uid_data["魔法穿透"]["基础"]
                uid_data["生命回复"]["当前"] = uid_data["生命回复"]["基础"]
                uid_data["魔力回复"]["当前"] = uid_data["魔力回复"]["基础"]

                for effect_list in uid_data["效果"]:
                    if effect_list["类型"] == "增益":
                        if effect_list["属性"] == "最大生命":
                            最大生命 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "最大魔力":
                            最大魔力 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "物攻":
                            物攻 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "魔攻":
                            魔攻 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "物防":
                            物防 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "魔防":
                            魔防 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "命中":
                            命中 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "闪避":
                            闪避 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴击":
                            暴击 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴伤":
                            暴伤 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴免":
                            暴免 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴抗":
                            暴抗 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "韧性":
                            韧性 *= (100 + effect_list["数值"]) / 100
                        elif effect_list["属性"] == "速度":
                            速度 *= (100 + effect_list["数值"]) / 100
                    elif effect_list["类型"] == "减益":
                        if effect_list["属性"] == "最大生命":
                            最大生命 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "最大魔力":
                            最大魔力 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "物攻":
                            物攻 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "魔攻":
                            魔攻 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "物防":
                            物防 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "魔防":
                            魔防 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "命中":
                            命中 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "闪避":
                            闪避 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴击":
                            暴击 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴伤":
                            暴伤 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴免":
                            暴免 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "暴抗":
                            暴抗 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "韧性":
                            韧性 *= (100 - effect_list["数值"]) / 100
                        elif effect_list["属性"] == "速度":
                            速度 *= (100 - effect_list["数值"]) / 100
                    elif effect_list["类型"] == "获得":
                        if effect_list["属性"] == "物理减伤":
                            uid_data["物理减伤"]["当前"] = round(float((1 - (100 - uid_data["物理减伤"]["当前"]) * (100 - float(effect_list["数值"])) / 10000) * 100), 2)
                        elif effect_list["属性"] == "魔法减伤":
                            uid_data["魔法减伤"]["当前"] = round(float((1 - (100 - uid_data["魔法减伤"]["当前"]) * (100 - float(effect_list["数值"])) / 10000) * 100), 2)
                        elif effect_list["属性"] == "物理增伤":
                            uid_data["物理增伤"]["当前"] += round(effect_list["数值"])
                        elif effect_list["属性"] == "魔法增伤":
                            uid_data["魔法增伤"]["当前"] += round(effect_list["数值"])
                        elif effect_list["属性"] == "物理穿透":
                            uid_data["物理穿透"]["当前"] = round(float((1 - (100 - uid_data["物理穿透"]["当前"]) * (100 - float(effect_list["数值"])) / 10000) * 100), 2)
                        elif effect_list["属性"] == "魔法穿透":
                            uid_data["魔法穿透"]["当前"] = round(float((1 - (100 - uid_data["魔法穿透"]["当前"]) * (100 - float(effect_list["数值"])) / 10000) * 100), 2)
                        elif effect_list["属性"] == "生命回复":
                            uid_data["生命回复"]["当前"] = round(float((1 - (100 - uid_data["生命回复"]["当前"]) * (100 - float(effect_list["数值"])) / 10000) * 100), 2)
                        elif effect_list["属性"] == "魔力回复":
                            uid_data["魔力回复"]["当前"] = round(float((1 - (100 - uid_data["魔力回复"]["当前"]) * (100 - float(effect_list["数值"])) / 10000) * 100), 2)

                uid_data["物攻"]["当前"] = max(math.ceil(uid_data["物攻"]["基础"] * 物攻), 1)
                uid_data["魔攻"]["当前"] = max(math.ceil(uid_data["魔攻"]["基础"] * 魔攻), 1)
                uid_data["生命"]["当前最大"] = max(math.ceil(uid_data["生命"]["基础最大"] * 最大生命), 1)
                uid_data["魔力"]["当前最大"] = max(math.ceil(uid_data["魔力"]["基础最大"] * 最大魔力), 1)
                uid_data["物攻"]["当前"] = max(math.ceil(uid_data["物攻"]["基础"] * 物攻), 1)
                uid_data["魔攻"]["当前"] = max(math.ceil(uid_data["魔攻"]["基础"] * 魔攻), 1)
                uid_data["物防"]["当前"] = max(math.ceil(uid_data["物防"]["基础"] * 物防), 1)
                uid_data["魔防"]["当前"] = max(math.ceil(uid_data["魔防"]["基础"] * 魔防), 1)
                uid_data["命中"]["当前"] = max(math.ceil(uid_data["命中"]["基础"] * 命中), 1)
                uid_data["闪避"]["当前"] = max(math.ceil(uid_data["闪避"]["基础"] * 闪避), 1)
                uid_data["暴击"]["当前"] = max(math.ceil(uid_data["暴击"]["基础"] * 暴击), 1)
                uid_data["暴伤"]["当前"] = max(math.ceil(uid_data["暴伤"]["基础"] * 暴伤), 1)
                uid_data["暴免"]["当前"] = max(math.ceil(uid_data["暴免"]["基础"] * 暴免), 1)
                uid_data["暴抗"]["当前"] = max(math.ceil(uid_data["暴抗"]["基础"] * 暴抗), 1)
                uid_data["韧性"]["当前"] = max(math.ceil(uid_data["韧性"]["基础"] * 韧性), 1)
                uid_data["速度"]["当前"] = max(math.ceil(uid_data["速度"]["基础"] * 速度), 1)
                for effect_list in uid_data["效果"]:
                    if effect_list["类型"] == "被装备":
                        if effect_list["名称"] == "诅咒":
                            uid_data["命中"]["当前"] = math.ceil(uid_data["命中"]["当前"] * (1 - 0.01 * effect_list["层数"]))
                            uid_data["闪避"]["当前"] = math.ceil(uid_data["闪避"]["当前"] * (1 - 0.01 * effect_list["层数"]))
                            uid_data["暴击"]["当前"] = math.ceil(uid_data["暴击"]["当前"] * (1 - 0.01 * effect_list["层数"]))
                            uid_data["暴伤"]["当前"] = math.ceil(uid_data["暴伤"]["当前"] * (1 - 0.01 * effect_list["层数"]))
                            uid_data["暴免"]["当前"] = math.ceil(uid_data["暴免"]["当前"] * (1 - 0.01 * effect_list["层数"]))
                            uid_data["暴抗"]["当前"] = math.ceil(uid_data["暴抗"]["当前"] * (1 - 0.01 * effect_list["层数"]))
                            uid_data["韧性"]["当前"] = math.ceil(uid_data["韧性"]["当前"] * (1 - 0.01 * effect_list["层数"]))
                            uid_data["速度"]["当前"] = math.ceil(uid_data["速度"]["当前"] * (1 - 0.01 * effect_list["层数"]))
                        if effect_list["名称"] == "撕裂":
                            uid_data["物防"]["当前"] = math.ceil(uid_data["物防"]["当前"] * (1 - 0.02 * effect_list["层数"]))
                            uid_data["魔防"]["当前"] = math.ceil(uid_data["魔防"]["当前"] * (1 - 0.02 * effect_list["层数"]))

        survivor_final = [sur for sur in data["玩家"] if sur["生命"]["当前"] > 0]
        monster_final = [sur for sur in data["敌人"] if sur["生命"]["当前"] > 0]
        if monster_final == []:
            finish = True
            boss_front = data["敌人"][0]["昵称"].split("的 ")[0]
            boss_name = data["敌人"][0]["昵称"].split(" ")[1]
            with open("data/boss_locate.txt", 'r') as f:
                boss_data = json.load(f)
            for boss_item in boss_data:
                if boss_item["名称"] == boss_name:
                    boss_item["存活"] = "否"
            with open("data/boss_locate.txt", 'w') as f:
                json.dump(boss_data, f, ensure_ascii=False, indent=4)
            txt1 = "\n=====★战斗胜利★====="
            front = ["普通", "精英", "王者", "深渊", "地狱", "猩红", "腐化", "神圣", "黄金", "璀璨", "梦幻"]
            front_exp = {"普通": 0, "精英": 50, "王者":100, "深渊": 150, "地狱": 200, "猩红": 300, "腐化": 300, "神圣": 300, "黄金": 300, "璀璨": 600, "梦幻": 1000}
            front_reward = {"普通": 0, "精英": 50, "王者": 150, "深渊": 250, "地狱": 400, "猩红": 500, "腐化": 500, "神圣": 500, "黄金": 600, "璀璨": 1200, "梦幻": 2000}
            if boss_front in front:
                txt1 += "\n♕{}加成♕\n经验+{}% 掉率+{}%".format(boss_front, front_exp[boss_front], front_reward[boss_front])

            # 遍历每个玩家，计算伤害总和，并添加到新列表中
            txt1 += "\n——————————————————\n✚✚✚✚战斗统计✚✚✚✚"
            total_list = []
            exp_add_mag = 1
            for player in data["玩家"]:
                if player["uid"] > 1000000:
                    continue
                if any(effect["名称"] == "献爱心" for effect in player["效果"]):
                    exp_add_mag += 0.25
                total = player["累计伤害"] + player["累计承伤"]
                total_list.append({"昵称": player["昵称"], "总评分": total, "伤害": player["累计伤害"], "承伤": player["累计承伤"]})
            # 使用sorted函数排序，键函数提取总伤害作为排序关键值
            sorted_players = sorted(total_list, key=lambda x: x["总评分"], reverse=True)
            for index, total_item in enumerate(sorted_players):
                if index == 0:
                    txt1 += "\n👑【{}】\n     [伤害]{}  [承伤]{}".format(total_item["昵称"], total_item["伤害"], total_item["承伤"])
                elif index == 1:
                    txt1 += "\n☀️【{}】\n     [伤害]{}  [承伤]{}".format(total_item["昵称"], total_item["伤害"], total_item["承伤"])
                elif index == 2:
                    txt1 += "\n🌙【{}】\n     [伤害]{}  [承伤]{}".format(total_item["昵称"], total_item["伤害"], total_item["承伤"])
                elif index == 3:
                    txt1 += "\n⭐️【{}】\n     [伤害]{}  [承伤]{}".format(total_item["昵称"], total_item["伤害"], total_item["承伤"])

            txt1 += "\n——————————————————\n=====🎉战斗结算🎉====="
            for in_player in data["玩家"]:
                if in_player["uid"] > 1000000:
                    continue
#                if await txt_exist("player", "number", number, "状态") != "战斗":
#                    continue
                uid = in_player["uid"]
                name = await player_name(uid)
                number = await player_number(uid)
                try:
                    task = await player_read(number, "任务")
                    for task_item in task:
                        for item in task_item["目标"]:
                            if item["类型"] == "讨伐" and item["对象"] == boss_name:
                                item["已讨伐"] += 1
                                break
                            elif item["类型"] == "单挑" and item["对象"] == boss_name and len(data["玩家"]) == 1:
                                item["已讨伐"] += 1
                                break
                    await player_write(number, "任务", None, task)
                except KeyError:
                    pass
  

                """哥布林特殊机制"""

                if any(in_player_effect["名称"] == "哥布林标记" for in_player_effect in in_player["效果"]):
                    for in_player_effect in in_player["效果"]:
                        if in_player_effect["名称"] == "哥布林标记":
                            effect_number = in_player_effect["层数"]
                    now_player_effect = await player_read(number, "特殊效果")
                    if any ("标记*哥布林标记" in in_effect for in_effect in now_player_effect):
                        for i, s in enumerate(now_player_effect):
                            if "标记*哥布林标记" in s:
                                num_index = s.rfind("*") + 1
                                num = int(s[num_index:]) + effect_number
                                now_player_effect[i] = s[:num_index] + str(num)
                    else:
                        now_player_effect.append("标记*哥布林标记*{}".format(effect_number))
                            
                    await player_write(number, "特殊效果", None, now_player_effect)

                now_player_effect = await player_read(number, "特殊效果")
                gbl_name1 = ["哥布林前哨", "哥布林先锋", "哥布林战士", "哥布林弩手"]
                gbl_name2 = ["巨魔战士", "野猪骑手", "巨魔重卫", "野猪重骑兵"]
                gbl_name3 = ["哥布林敢死队", "哥布林精锐", "哥布林炮手", "哥布林巫师"]
                if boss_name == "哥布林上校":
                    for in_now_player_effect in now_player_effect:
                        if "标记*哥布林标记" in in_now_player_effect:
                            now_player_effect.remove(in_now_player_effect)
                            break
                elif boss_name in gbl_name1 or boss_name in gbl_name2 or boss_name in gbl_name3:
                    if boss_name in gbl_name1:
                        gbl_buff = 1
                    elif boss_name in gbl_name2:
                        gbl_buff = 3
                    elif boss_name in gbl_name3:
                        gbl_buff = 6
                    if any("标记*哥布林标记" in in_effect for in_effect in now_player_effect):
                        for i, s in enumerate(now_player_effect):
                            if "标记*哥布林标记" in s:
                                num_index = s.rfind("*") + 1
                                num = int(s[num_index:]) + gbl_buff
                                now_player_effect[i] = s[:num_index] + str(num)
                                break
                    else:
                        now_player_effect.append("标记*哥布林标记*{}".format(gbl_buff))

                await player_write(number, "特殊效果", None, now_player_effect)


                await player_write(number, "生命", "当前", in_player["生命"]["当前"])
                await player_write(number, "魔力", "当前", in_player["魔力"]["当前"])
                        
                        
                if int(await player_read(number, "体力")) <= 0 and boss_front not in front:
                    txt1 += "\n◈【{}】过度疲惫，难以再回应世界的馈赠".format(name)
                    await txt_write("player", "number", number, "状态", "行动")
                    continue
                        
                        
                exp_add = data["敌人"][0]["经验"]
                #新春祝福
                exp_add *= exp_add_mag
                
                if boss_front in front:
                    exp_add = exp_add * (100 + front_exp[boss_front]) / 100
                level_gap = data["敌人"][0]["等级"] - in_player["等级"]
                if level_gap > 10:
                    exp_add = math.floor(exp_add / 3)
                elif level_gap == 10:
                    exp_add = math.floor(exp_add * 0.5)
                elif level_gap == 9:
                    exp_add = math.floor(exp_add * 0.6)
                elif level_gap == 8:
                    exp_add = math.floor(exp_add * 0.7)
                elif level_gap == 7:
                    exp_add = math.floor(exp_add * 0.8)
                elif level_gap == 6:
                    exp_add = math.floor(exp_add * 0.9)

                exp_add = math.ceil(exp_add)

                txt1 += "\n◈【{}】EXP +{}".format(name, exp_add)
                exp_now = await player_read(number, "经验", "当前")
                exp_now = int(exp_now) + int(exp_add)
                level = await player_read(number, "等级")
                exp_max = await exp_up(level)
                while exp_now >= exp_max:
                    level_max = int(await player_read(number, "灵阶")) * 10
                    if int(level) >= level_max:
                        exp_now = exp_max
                        txt1 += "\n◈精纯的能量涌入你的体壳，然后向外四溢，消散在了空中。。。"
                        break
                    point = await player_read(number, "属性点") + 1
                    await player_write(number, "属性点", None, point)
                    exp_now -= exp_max
                    level += 1
                    exp_max = await exp_up(level)
                    txt1 += "\n◈【{}】升到{}级\n获得属性点，可以[属性分配]".format(name, level)
                            

                    """进化机制"""
                    if int(await player_read(number, "灵阶")) == 3:
                        with open(f"data/进化词条.txt", 'r') as f:
                            evolute = json.load(f)
                        random_evolute = random.choice(evolute)
                        player_evolute = await player_read(number, "进化")
                        while True:
                            count = 0
                            for every_evolute in player_evolute:
                                if every_evolute["部位"] == random_evolute["部位"]:
                                    if random_evolute["词条"] == every_evolute["词条"]:
                                        random_evolute = random.choice(evolute)
                                        break
                                    else:
                                        count += 1
                            else:
                                break
                        if count >= 5:
                            evolute_percent = 0
                        else:
                            evolute_percent = 0.5 ** (count - 1)
                        if random.random() < evolute_percent:
                            num_range = random_evolute["数值"].split("-")
                            num_min = float(num_range[0])
                            num_max = float(num_range[1])
                            random_num = round(random.uniform(num_min, num_max), 2)
                            random_evolute["数值"] = random_num
                            player_evolute.append(random_evolute)
                            await player_write(number, "进化", None, player_evolute)

                        if random.random() < 0.75:
                            player_unevolute = await player_read(number, "进化诅咒")
                            with open(f"data/进化诅咒.txt", 'r') as f:
                                unevolute = json.load(f)
                            unevolute = [d for d in unevolute if d['部位'] == random_evolute["部位"]]
                            random_unevolute = random.choice(unevolute)
                            while True:
                                count = 0
                                for every_unevolute in player_unevolute:
                                    if random_unevolute["部位"] == every_unevolute["部位"]:
                                        if random_unevolute["词条"] == every_unevolute["词条"]:
                                            random_unevolute = random.choice(unevolute)
                                            break
                                        else:
                                            count += 1
                                else:
                                    break
                            if count < 4:
                                num_range = random_unevolute["数值"].split("-")
                                num_min = float(num_range[0])
                                num_max = float(num_range[1])
                                random_num = round(random.uniform(num_min, num_max), 2)
                                random_unevolute["数值"] = random_num
                                player_unevolute.append(random_unevolute)

                                await player_write(number, "进化诅咒", None, player_unevolute)
                                    
                    """进化机制"""


                await player_write(number, "经验", "当前", exp_now)
                await player_write(number, "经验", "最大", exp_max)
                await player_write(number, "等级", None, level)

                all_reward = {}
                for reward in data["敌人"][0]["掉落"]:
                    if boss_front not in reward.get("条件", ["普通", "精英", "王者", "深渊", "地狱", "猩红", "腐化", "神圣", "黄金", "璀璨", "梦幻", "大力", "神力", "聪明", "聪慧", "灵活", "灵巧", "强壮", "强健", "全能", "超能", "庞大", "犀利", "胆小", "精明", "谨慎", "狠毒", "稳重", "无感", "迅捷", "血腥", "坚硬", "狡黠", "精锐", "一般", "羸弱"]):
                        continue
                    ran = random.uniform(0, 100)
                    gailv = float(reward["概率"])
                    if boss_front in front:
                        gailv = gailv * (100 + int(front_reward[boss_front])) / 100
                    
                    if level_gap > 15:
                        gailv = 0
                    elif level_gap == 15:
                        gailv = gailv * 0.1
                    elif level_gap == 14:
                        gailv = gailv * 0.2
                    elif level_gap == 13:
                        gailv = gailv * 0.4
                    elif level_gap == 12:
                        gailv = gailv * 0.6
                    elif level_gap == 11:
                        gailv = gailv * 0.8
                    if ran < gailv:
                        if reward["名称"] in all_reward:
                            all_reward[reward["名称"]] += int(reward["数量"])
                        else:
                            all_reward[reward["名称"]] = int(reward["数量"])
                for key, value in all_reward.items():
                    await bag_add(uid, key, value)
                    txt1 += "\n◈【{}】获得 [{}]×{}".format(name, key, value)


                if in_player["生命"]["当前"] == 0:
                    await txt_write("player", "number", number, "状态", "强制休息")
                    await txt_write("player", "number", number, "休息时间", int(time.time()))
                elif await txt_exist("player", "number", number, "状态") != "教程5":
                    await txt_write("player", "number", number, "状态", "行动")
                power = int(await player_read(number, "体力")) - 1
                await player_write(number, "体力", None, power)



            if "教程" in await txt_exist("player", "number", number, "状态"):
                txt2 = "\n🎉恭喜你，完成了第一次击杀！\n🎉接下来的路将由你开拓！\n◈发送[上][下][左][右]进行探索"
                await txt_write("player", "number", number, "状态", "行动")
                await send_message(message, 3, 5, txt2)
                    

            all_auto = True
            with open(f"data/battle/{battle_id}.txt", 'r') as f:
                data = json.load(f)
            for item in data["玩家"]:
                if item.get("自动战斗", "否") == "否":
                    all_auto = False

            os.remove(f"data/battle/{battle_id}.txt")
            await txt_write("player", "number", number, "状态", "行动")
            asyncio.create_task(send_message(message, 2, 3, txt1))
            return txt

        if survivor_final == []:
            txt1 = "\n===☠战斗失败☠==="
            for uid in result:
                if uid > 1000000:
                    continue
                if uid != 0:
                    name = await player_name(uid)
                    number = await player_number(uid)
                    lose_exp = math.floor(int(await player_read(number, "经验", "当前")) / 2)
                    if lose_exp > math.floor(int(await player_read(number, "经验", "最大")) / 50):
                        lose_exp = math.floor(int(await player_read(number, "经验", "最大")) / 50)

                            
                    now_exp = await player_read(number, "经验", "当前") - lose_exp
                    txt1 += "\n◈【{}】损失经验{}".format(name, lose_exp)
                    await player_write(number, "经验", "当前", now_exp)
                    await player_write(number, "生命", "当前", 0)
                    await player_write(number, "魔力", "当前", 0)
                    await txt_write("player", "number", number, "状态", "强制休息")
                    await txt_write("player", "number", number, "休息时间", int(time.time()))


                    """哥布林机制，战败标记清空"""
                    now_player_effect = await player_read(number, "特殊效果")
                    for in_now_player_effect in now_player_effect:
                        if "标记*哥布林标记" in in_now_player_effect:
                            now_player_effect.remove(in_now_player_effect)
                            break
                    await player_write(number, "特殊效果", None, now_player_effect)

            os.remove(f"data/battle/{battle_id}.txt")
            asyncio.create_task(send_message(message, 2, 3, txt1))
            return txt

#        for item in data["敌人"]:
#            if item["uid"] == uid:
#                enemy_data = item
#                break

    data["回合"] += 1


    with open(f"data/battle/{battle_id}.txt", 'w') as f:
        json.dump(data, f, ensure_ascii=False, indent=4)
    all_auto = True
    with open(f"data/battle/{battle_id}.txt", 'r') as f:
        data = json.load(f)
        bt_round = data["回合"]
        for item in data["玩家"]:
            if item.get("自动战斗", "否") == "否":
                all_auto = False
            else:
                auto_skills = item["自动战斗顺序"].split("-")
                auto_total = len(auto_skills)
                now_skill_num = int(bt_round) % int(auto_total)
                if now_skill_num == 0:
                    now_skill_num = int(auto_total)
                now_skill = auto_skills[now_skill_num - 1]
                try:
                    if int(now_skill) <= len(item["技能"]):
                        if now_skill == "0":
                            item["出招"] = "普攻"
                        else:
                            item["出招"] = "技能{}".format(now_skill)
                    else:
                        item["出招"] = "普攻"
                except ValueError:
                    item["出招"] = "普攻"
    with open(f"data/battle/{battle_id}.txt", 'w') as f:
        json.dump(data, f, ensure_ascii=False, indent=4)
  
    if all_auto:

        txt0 = await battle_round(message)
        txt0 = txt0 if txt0 is not None else ""
        txt += "\n◆◇◆◇◆◇◆◇◆◇◆◇" + txt0
        return txt
               
    else:

        await send_message(message, 1, 2, txt)
        return  




async def boss_battle(enemy, bt_round, HP, Max_HP, counter):
    return_txt = {}
    if "木桩" in enemy:
        return_txt = {"技能": "嘲讽", "描述": "【一动不动】"}

    if "森林史莱姆" in enemy:
        if int(bt_round) == 1:
            return_txt = {"技能": "毒气", "描述": "【绿色的团子反复蠕动，发出了 “噗叽噗叽” 声————】"}
        if int(bt_round) == 2:
            return_txt = {"技能": "强撞", "描述": "【嘭咚！】\n【绿色团子狠狠地撞来————】"}
        if int(bt_round) == 3:
            return_txt = {"技能": "压顶", "描述": "【哐叽！】\n【从天而降————】"}
        if int(bt_round) == 4:
            return_txt = {"技能": "治愈", "描述": "【噗休噗休】"}

    if "岩石史莱姆" in enemy:
        if int(bt_round) == 1:
            return_txt = {"技能": "固体"}

        if int(bt_round) == 2:
            return_txt = {"技能": "崩地"}

        if int(bt_round) == 3:
            return_txt = {"技能": "压扁"}

        if int(bt_round) == 4:
            return_txt = {"技能": "崩地"}

        if int(bt_round) == 5:
            return_txt = {"技能": "强撞"}


    if "大学者[噶]" in enemy:
        if int(bt_round) == 1:
            return_txt = {"技能": "魔法吟咏", "描述": "【“魔力，眷顾于我——”】"}

        if int(bt_round) == 2:
            return_txt = {"技能": "碧波荡漾", "描述": "【“这魔力的滋味，犹如我年轻时的光彩。”】"}

        if int(bt_round) == 3:
            return_txt = {"技能": "苍蓝射线", "目标": "生命最低", "描述": "【“要注意哦，团队的弱点所在——”】"}

        if int(bt_round) == 4:
            return_txt = {"技能": "酸雨", "描述": "【“腐蚀一切吧！”】"}

        if int(bt_round) == 5:
            return_txt = {"技能": "全神贯注", "描述": "【“我感知到了你们的气息——”】"}

        if int(bt_round) == 6:
            return_txt = {"技能": "水龙卷", "描述": "【“天翻地覆吧！”】"}

        if int(bt_round) == 7:
            return_txt = {"技能": "苍蓝射线", "描述": "【“嘿嘿，这一下怎样！”】"}

    if "刺毛猪" in enemy:

        if counter.get("阶段", 1) == 1:

            if HP < 0.5 * Max_HP:

                counter["阶段"] = 2
                counter["狂暴回合"] = 0
                return_txt = {"技能": "血怒", "描述": "【“快看，它红温了！！！”】", "计数器": counter}
                return return_txt

            else:

                if int(bt_round) % 4 == 1:
                    return_txt = {"技能": "蓄势", "描述": "【猪猪拱起尖牙，全身尖刺竖起——】"}

                elif int(bt_round) % 4 == 2:
                    return_txt = {"技能": "万刺齐发", "描述": "【“嘭！”】\n【什么东西炸开了！】"}

                elif int(bt_round) % 4 == 3:
                    return_txt = {"技能": "猪突猛进", "描述": "【一道影子快如闪电——】"}

                elif int(bt_round) % 4 == 0:
                    return_txt = {"技能": "滚刺", "描述": "【刺球冲撞！】"}

        if counter.get("阶段", 1) == 2:

            if HP < 0.1 * Max_HP:

                return_txt = {"技能": "死袭", "目标": "生命最低", "描述": "【宁死不屈！！！】", "计数器": counter}
                return return_txt

            counter["狂暴回合"] += 1
            if counter.get("狂暴回合", 1) == 1:
                return_txt = {"技能": "蓄势", "描述": "【猪猪开始了蓄力——】", "计数器": counter}
            elif counter.get("狂暴回合", 1) == 2:
                return_txt = {"技能": "暴雨梨花刺", "描述": "【梨花带雨，人见尤伤！】", "计数器": counter}
            elif counter.get("狂暴回合", 1) % 3 == 0:
                return_txt = {"技能": "滚刺", "描述": "【难以避其锋芒！】", "计数器": counter}
            elif counter.get("狂暴回合", 1) % 3 == 1:
                return_txt = {"技能": "猪突猛进", "描述": "【疾如闪电！】", "计数器": counter}
            elif counter.get("狂暴回合", 1) % 3 == 2:
                return_txt = {"技能": "万刺齐发", "描述": "【“嘭！”】\n【再次炸裂！】", "计数器": counter}

    if "无名剑圣" in enemy:
        if int(bt_round) == 1:
            return_txt = {"技能": "拭剑", "描述": "【剑心一拭敛寒芒————】"}
        elif int(bt_round) == 2:
            return_txt = {"技能": "持鞘", "描述": "【全心全意的一剑————】"}
        elif int(bt_round) == 3:
            return_txt = {"技能": "剑刃风暴", "描述": "【无终乱刃！】"}
        elif int(bt_round) == 4:
            return_txt = {"技能": "剑刃风暴", "描述": "【再来！！！】"}
        else:
            return_txt = {"技能": "剑刃风暴", "描述": "【再来！！！】"}

    if "无名剑影" in enemy:
        if int(bt_round) % 4 == 1:
            return_txt = {"技能": "拭剑", "描述": "【看好了————】"}
        elif int(bt_round) % 4 == 2:
            return_txt = {"技能": "速击", "描述": "【接住！】"}
        elif int(bt_round) % 4 == 3:
            return_txt = {"技能": "速击", "描述": "【！！！】"}
        elif int(bt_round) % 4 == 0:
            return_txt = {"技能": "重击", "描述": "【见识到了吗？！】"}


    if "昔日神官" in enemy:
        if int(bt_round) % 4 == 1:
            return_txt = {"技能": "波澜不惊", "描述": "【放轻松————】"}
        elif int(bt_round) % 4 == 2:
            return_txt = {"技能": "水波", "描述": "【睡过去吧。】"}
        elif int(bt_round) % 4 == 3:
            return_txt = {"技能": "水波", "描述": "【睡过去吧。】"}
        elif int(bt_round) % 4 == 0:
            return_txt = {"技能": "治愈", "描述": "【还没意识到吗。】"}

    
    return return_txt


    
            

